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

Home » Public Forums » archive » Re: Fast shear
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: Fast shear [message #29122] Tue, 05 February 2002 09:42 Go to previous message
Wayne Landsman is currently offline  Wayne Landsman
Messages: 117
Registered: January 1997
Senior Member
the_cacc@hotmail.com wrote

> Anyone know a way of doing the following as fast as possible:
> for i = 0, n-1 DO array[*,i] = SHIFT(array[*,i],delta[i])
> where delta is an INTARR.

Well, I think a loop over rows is necessary, but the speed can be vastly
improved by using the folllowing IDL maxim for efficient programming,
which gets my vote in the "IDL maxim most deserving of wider
recognition" category.

"Avoid the use of an asterisk on the left-hand side of an assignment."

which in this case means to rewrite the assignment as

for i = 0, n-1 DO array[0,i] = SHIFT(array[*,i],delta[i])

For a fltarr(2048,2048) on my Solaris machine running V5.5, I find a
factor of 15 improvement in speed.

I believe that one uses an asterisk on the left hand side, that
IDL first creates a temporary variable, places the contents of the right
hand side into this temporary variable, and then places the temporary
variable back into array. By specifying array[0,i] one directly
gives the starting location where to place the contents of the right
hand side.


--Wayne Landsman
landsman@mpb.gsfc.nasa.gov
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: StrSplit wont port to Windows?
Next Topic: Re: Slow array indexing

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

Current Time: Wed Oct 08 13:54:20 PDT 2025

Total time taken to generate the page: 0.00184 seconds