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

Re: array indices again



Henry Chapman wrote:
> 
> Hi all,
> 
> I remember a few weeks back there was a lot of discussion about indexing
> multiple dimensions of arrays, [...]

> It seems that by extending the 2-d array a into another dimension, where
> the extra dimension has no size (sounds like string theory!) the
> indexing works the way I want it to.  I noticed this when I had a 3-d
> array and was extracting a 2-d array from it, as in b[x, x, i] where x
> is a 1-d array and i is a scalar.  This seems to work on arrays of any
> dimension.
> 
> I apologise if this was mentioned before,
> 
> Henry.
> 
> --
> Henry Chapman                          mailto:chapman9@llnl.gov
> Information Science & Technology Program
> Lawrence Livermore National Lab
> L-395, 7000 East Ave., Livermore CA 94550

Henry,

   nice feature! I was really astonished when I saw it works even for
non-equal dimensions:
     a = findgen(20,10) 
     x = indgen(10)*2
     y = indgen(5)*2
     print,a[x,y,0]

however, (a puzzle for the unexperienced IDL user):
     print,a[x,y]
will result in an error message... 

Martin.


-- 

|||||||||||||||\\\\\\\\\\\\\-------------------///////////////|||||||||||||||
Martin Schultz, DEAS, Harvard University, 29 Oxford St., Pierce 109,
Cambridge, MA 02138          phone (617) 496 8318   fax (617) 495 4551
e-mail mgs@io.harvard.edu    web http://www-as/people/staff/mgs/