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

Re: Gridding options




"J.D. Smith" <jdsmith@astro.cornell.edu> writes:

> Ben Tupper wrote:
> > (Sorry, JD, it does have loopity-loops.  You can flick a worm into the
> > air... but that doesn't mean it knows how to fly!  I'm still trying to
> > figure out what .....
> > 
> ****************************************
> tt=total(a[(((dy=((di=lindgen(((n=nx<ny)),nx+ny-1)))/n))*(nx gt ny?1:nx)+ $
>               (nx gt ny?1:-1)*((dx=di mod n))*(nx-1))>0<(nx*ny-1)]* $
>            (dy ge dx AND (dy-dx) lt nx>ny),1)
> ****************************************
> > 
> > means.   Maybe I need to drink less/more coffee. )
> 
> It's written in an ancient IDL runic language lost in the dark ages (1993). 
> Simply run it on an array "a" after defining the dimensions "nx" and "ny" and
> all will be clear.

Another disadvantage to vectorizing with very large arrays is that IDL
has to generate the indices for the array dynamically.  This can
consume a lot of memory (sometimes more than the array itself, if it's
a byte or int array!).  The expression, lindgen((nx<ny), nx+ny-1),
[some deleted] is the giveaway that JD had to essentially create a
whole new array even bigger than the original.  Still, it's a pretty
impressive computation.

Todd, did you compare the run time?

Craig

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