[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
array indices again
- Subject: array indices again
- From: Henry Chapman <chapman(at)rosella.llnl.gov>
- Date: Thu, 03 Jun 1999 10:22:52 -0700
- Newsgroups: comp.lang.idl-pvwave
- Organization: Lawrence Livermore National Laboratory
- Reply-To: chapman9(at)llnl.gov
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:15036
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