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

Home » Public Forums » archive » Fast shear
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Fast shear [message #29128] Tue, 05 February 2002 05:00 Go to next message
the_cacc is currently offline  the_cacc
Messages: 104
Registered: October 2001
Senior Member
Hi,

Anyone know a way of doing the following as fast as possible:

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

or, even better,

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

where delta is an INTARR.


Ciao.

(NB. using IDL5.5 - when it works ;))
Re: Fast shear [message #29197 is a reply to message #29128] Thu, 07 February 2002 04:53 Go to previous message
Martin Downing is currently offline  Martin Downing
Messages: 136
Registered: September 1998
Senior Member
> Wayne Landsman <landsman@mpb.gsfc.nasa.gov> wrote in message
news:<3C60199D.E4810C70@mpb.gsfc.nasa.gov>...
>>
>> "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.
>>
>
> WOW! Wayne, that's magic. I get 10-15X speed-up. The world *has* to be
> told about this. One drawback - the code does not strictly make sense,
> hell who cares !?
>
I second that WOW! I had not realised that by specifying a single cell of
an image on the left hand side allows intelligent access to the elements
mapped by the dimensional shape of the right hand side. Offset assignments
in 2/3d images become a breeze.

e.g. to set image[100:109,100:129] = 255:
image[100,100] = replicate(255, 10, 30)

I had stupidly assumed that the assignment would follow C language rules and
fill in a raster ordering.
Thanks for the tip - I will be using this method from now on

Martin
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: CFD with IDL ???
Next Topic: Re: IDL crashes using CONTAINSPOINTS (not any more)

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

Current Time: Wed Oct 08 13:05:23 PDT 2025

Total time taken to generate the page: 0.00497 seconds