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

Home » Public Forums » archive » look, no 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
look, no loops! [message #6427] Wed, 12 June 1996 00:00
Robert Cannon is currently offline  Robert Cannon
Messages: 5
Registered: February 1996
Junior Member
These postings about loops seem to show that the basic array
manipulation routines in IDL are not quite as clear as they could be.

If you want to make a 2d array with a(i,j) = j you cna do it with

a = lindgen(nx, ny) mod nx
OR a = lindgen(nx) # (intarr(ny) + 1)
OR a = rebin (lindgen(nx), nx, ny)
OR ...others?

But why should you have to? - You dont see many Yorick plugs on
this group, but almost everything I do in IDL (with the
crucial esception of widget applications) could be done better in
Yorick - and it is free.


eg, the above would be
a = span(1,nx,nx)(,-:1:ny)

Yorick indices start at one. The "-:1:ny" adds an index to the 1-D
array and copies the first row ny times.
You can add as many diomensions as you like; a(,,-,-) is a 4-D array
with the last two dimesnsions equal to one.

Or, if you want the maximum along a particular dimension, you have:

maxx = a(max,) a vector where each elementt is the max of a row
maxy = a(,max) ... column

etc, etc for arbitrary arrays.

Likewise, you can do a generalised matrix multiplication of a pair of
arrays along any dimensions by marking the dimensions you want to
contract with a + sign:
a (+,) * b(,+) for an ordinary matrix multiplication.



Well, I'm very impressed by Yorick, and thought maybe
someone else who was fed up with writing messy idl loops might be
interested. It was written by David H. Munro at Lawrence Livermore
National Laboratory. I dont know if there is a home page, but some info
is at:

http://netlib.org/env/yorick.readme
and
http://hpux.ee.ualberta.ca/hpux/Physics/yorick-1.0.html


Regards, Robert Cannon


Neuroscience Research Group
Southampton UK, SO16 7PX

tel: (0)1703 594286
Fax: (0)1703 594319
rcc@hera.neuro.soton.ac.uk
[Message index]
 
Read Message
Previous Topic: Grid lines on contour plots
Next Topic: call_external and threads (Solaris)

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

Current Time: Sat Oct 11 10:15:23 PDT 2025

Total time taken to generate the page: 1.14365 seconds