Re: Using MIN on arrays : Exorcising loops? [message #27043 is a reply to message #27036] |
Sun, 07 October 2001 16:25   |
Andrew Cool
Messages: 219 Registered: January 1996
|
Senior Member |
|
|
Martin Downing wrote:
>
> "Craig Markwardt" <craigmnet@cow.physics.wisc.edu> wrote in message
> news:on3d4yw86j.fsf@cow.physics.wisc.edu...
>>
>> Andrew Cool <cooladjc@chariot.net.au> writes:
>>
> .....
>
> Hi Andrew & Craig
>
> For a simple case like this, why not just use:
> Min_array = data_array[*,*,0] < data_array[*,*,1] < data_array[*,*,2]
>
> Martin
G'day Martin,
Now that I'm back at work, I regret to advise that your approach
doesn't work. Craig's, however, does :-
> data_array = Fltarr(640,500,NZ)
> Min_array = data_array(*,*,0)
>
> for i = 1, NZ-1 do $
> min_array = min_array < data_array(*,*,i)
It seems that you need to have an initial test condition before you
start applying those < operators. Not being a math-head, that might
not be the right jargon to describe it.
The use of the < operator has cut the time taken from about 1.03
seconds
for the double x,y loop to about 0.008 seconds using <, including the
initialisation statement Min_array = data_array(*,*,0).
I'm happy!
Cheers,
Andrew
|
|
|