Re: Using MIN on arrays : Exorcising loops? [message #27017] |
Mon, 08 October 2001 12:58  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
andrew cool <andrew.cool@dsto.defence.gov.au> writes:
> Martin Downing wrote:
>> 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.
I would have thought both approaches would have worked, and been about
the same speed. That is curious. The advantage to my approach is
that NZ, the size of the third dimension, can be variable; and the
advantage of Martin's is that it all fits one one line (but the number
is hardcoded).
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|