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

Home » Public Forums » archive » Re: Subscripting multidimensional arrays
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Subscripting multidimensional arrays [message #37271 is a reply to message #37269] Fri, 12 December 2003 13:15 Go to previous messageGo to previous message
Chris Lee is currently offline  Chris Lee
Messages: 101
Registered: August 2003
Senior Member
JD Smith wrote:
> On Fri, 12 Dec 2003 07:55:16 -0700, Christopher Lee wrote:
<snip>
>
> PRODUCT works nicely for this:
>
> function linear_indices,array,vec_indices
> s=size(array,/DIMENSIONS)
> nd=n_elements(s)
> if nd eq 1 then return,s[0]

;you mean "return ,vec_indices" , yes?

> return,long(total([1.,product(s[0:nd-1],/CUMULATIVE)]*vec_in dices))
> end

PRODUCT doesn't seem to exist on my IDL installations (5.3->5.6
inclusive), is it an IDL 6 thing? I've written my own obviously, but not
with CUMULATIVE. Hopefully the IDL 6 licence will work on Monday.


>
> to go the other direction, IDL6 offers ARRAY_INDICES. Or you can always
> just resort to:
>
> a[vec[0],vec[1],vec[2]]
>

Ahem, oops. Apparently I used a cluster bomb to open a can of beans...a
switch case statement would take care of the dimensions upto the IDL
limit of 8 dimensions, or using IDL's ability to ignore trailing
dimensions if they're 0 hack to use 8 dimensions every time.




> A take home problem would be to modify this such that NxM input vectors,
> where N is the number of dimensions of "array", will return a vector of
> length M containing all the 1-D indices. Hints: REBIN/REFORM and the
> "dimension" argument to TOTAL.
>

I got that exercise too, but I thought I'd leave some fun for other
people :) plus I always get into a "but what if I wanted the input
vector to be MxN" and "what if not enough arguments are supplied, or
they're out of bounds" and I remember I have work to do, sometimes.

> JD

Chris.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: rebinning data on new time samples without loops?
Next Topic: Re: 2D FFT Slow. Any ideas? fft2()

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

Current Time: Sat Oct 11 05:31:53 PDT 2025

Total time taken to generate the page: 0.32385 seconds