[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Generally accessing the rest of the elements in an array
William Thompson wrote:
> "tbowers" <email@example.com> writes:
> >How do I access the 2nd + dimensions of an array generally, without knowing
> >number of higher dims this array has. E.g. say a is a 3 column by
> >aray, and n is unknown. Here, I'll define it as:
> >a = indgen(3,2,4)
> >I want the equivalent of (in this case):
> >b = (a[0,*,*])^2 + (a[1,*,*])^2 + (a[2,*,*])^2
> (rest deleted)
> You should be able to do something like the following:
> b = a[0,*,*,*,*,*,*,*]^2 + a[1,*,*,*,*,*,*,*]^2 + a[2,*,*,*,*,*,*,*]^2
I think Mr/Dr Bowers should think about a new data structure that can deal with the
flexibility he requires. An IDL structure perhaps?
When you start using arrays of more than three or four dimensions, and this is my very
personal viewpoint only, I would definitely spend a couple of hours thinking about how to
repackage either the data in the code or the code itself to change the "flow of data"
(insert hand-waving here) to avoid the type of expressions like the above.
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
firstname.lastname@example.org Alexander Pope.