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

Re: Dos and Donts

brinks wrote:
> I'm preparing a little talk about efficient programming in IDL. From the
> help files and from my own experience I found many hints about 'what to
> do and not to do' to speed up code in IDL. The most things I listed so
> far are about array operations and data arrangement, avoiding loops etc.
> Taking an intensive look into the help system I found some little tricks
> to improve speed, e.g. using rotation for image rotation by 90 deg
> rather than rot(...,90). Up to now I didn't know that there is a
> difference at all.
> I am sure there are many more odds and ends to improve IDL code. Does
> anyone out there can give my a hint where to find more of those tricks?
> Links, recommendation of a book, or just some direct tips would be very
> helpfull.


http://www.sf.med.va.gov/mrs/IDL/idl_docs.htm#MEMORY USAGE REDUCTION IN

And the online document 'Building IDL applications', section
'Programming in IDL'.

And finally, one from me. The TEMPORARY function can often be used to
conserve memory. However it's not immediately obvious (at least it
wasn't to me until recently) how to use TEMPORARY when extracting an
array subset.

For example, TEMPORARY saves no memory in the following example:

a = dist(256)
b = temporary(a[0:63, 0:63])
help, a, b
A               FLOAT     = Array[256, 256]
B               FLOAT     = Array[64, 64]

The argument a[0:63, 0:63] is passed to TEMPORARY by value, and
therefore cannot be modified. However the following method *does* save

a = dist(256)
b = (temporary(a))[0:63, 0:63]
help, a, b
A               UNDEFINED = <Undefined>
B               FLOAT     = Array[64, 64]