[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Philosophy of for loops




edward.s.meinel@aero.org writes:
> 
> So does that mean that form (3) is slower than form (1)?
> 
> (3) for j=0,2047 do   $
>        for i=0,2047 do $
>           outarr[i,j]=median(inarr[*,i,j])
> 

No, I think your form (3) would be interpretted as a single line, so
it would be equivalent to form (2).  The following form (4) would be
slightly slower than (1), but keep in mind that small amounts of
processing in the outer loop are pretty much negligible.

for j = 0, 2047 do begin
  for i = 0, 2047 do begin
       outarr[i,j]=median(inarr[*,i,j])
  endfor
endfor

Craig

-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------