Re: sum and for loop too slow...
- From: "Titus Edelhofer" <titus.edelhofer@xxxxxxxxxxxx>
- Date: Wed, 3 May 2006 15:19:54 +0200
Hi,
1000000 are many, so you should be careful about what you do.
You sum up 27*100000 times more or less the same, so the first
suggestion I have is:devide sum(0:0.001:2000+zeta(i,j)) into
sum(0:0.001:1995)+sum(1995.001:0.001:2000+zeta)
And the first part is not dependent on i,j ...
Titus
"Evan" <evanmason@xxxxxxxxx> schrieb im Newsbeitrag
news:1146661276.745599.229150@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi, can anyone suggest a way to speed up the following bit of code:
pressure = zeros(27,1000000);
for i=1:27
for j=1:1000000
pressure(i,j) = sum(0 : 0.001 : 2000+zeta(i,j));
end
end
'zeta' is an array (27,1000000) containing random floats between -5 and
5. Ideally I'd like to get rid of the 'for' loops as these are taking
all the time, but not sure how/if possible?
Many thanks,
Evan
.
- References:
- sum and for loop too slow...
- From: Evan
- sum and for loop too slow...
- Prev by Date: Re: Zero crossing with fixed step size solver
- Next by Date: Re: sum and for loop too slow...
- Previous by thread: sum and for loop too slow...
- Next by thread: Re: sum and for loop too slow...
- Index(es):
Relevant Pages
|
Loading