comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Philosophy of for loops
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Philosophy of for loops [message #21486] Tue, 29 August 2000 00:00 Go to previous message
landsman is currently offline  landsman
Messages: 93
Registered: August 1991
Member
Todd Clements wrote:
>>
>> Hello, again, everyone!
>>
>> I was just wondering what the general concensus of the "IDL Expert
>> Programmers" was on the use of for loops. When I first learned IDL,

A related question is when is it better to write loops as a single line,
and when is it better to use a DO BEGIN construct. For example,

inarr= randomn(seed, 3, 2048,2048)
outarr = fltarr(2048,2048,/nozero)

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

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

Form (1) is slightly faster, but the calculation cannot be interrupted
with a Control-C. Also, it is my impression that the speed difference
is less than it used to be, and that form (2) is now better optimized.

(I also assume that the two FOR loops are unavoidable here, but I would
be delighted to be proved wrong.)

--Wayne Landsman landsman@mpb.gsfc.nasa.gov


Sent via Deja.com http://www.deja.com/
Before you buy.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: HDF-EOS - revisited
Next Topic: Re: Standalone executables (was Origin of IDL)

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:53:39 PDT 2025

Total time taken to generate the page: 0.00373 seconds