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

Home » Public Forums » archive » array indices again
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
array indices again [message #15631] Thu, 03 June 1999 00:00
Henry Chapman is currently offline  Henry Chapman
Messages: 10
Registered: February 1997
Junior Member
Hi all,

I remember a few weeks back there was a lot of discussion about indexing
multiple dimensions of arrays, and doing things such as

IDL> print,(a[x,*])[*,x]

I just noticed something that may or may not have come up in those
discussions (but I wasn't paying attention). It is most easily
explained by Liam's example of extracting every second row and column of
an array

IDL> a=indgen(10,10)
IDL> x=indgen(5)*2
IDL> print, a[x, x, 0]
0 2 4 6 8
20 22 24 26 28
40 42 44 46 48
60 62 64 66 68
80 82 84 86 88

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
Re: array indices again [message #15723 is a reply to message #15631] Thu, 03 June 1999 00:00 Go to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
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/
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDL and Dual Processor PC's
Next Topic: Re: IDL interface to Oracle

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

Current Time: Wed Oct 08 19:51:12 PDT 2025

Total time taken to generate the page: 0.00558 seconds