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

Home » Public Forums » archive » Re: Q: Indexing arrays with variable # dimensions
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: Q: Indexing arrays with variable # dimensions [message #4803] Thu, 10 August 1995 00:00
rivers is currently offline  rivers
Messages: 228
Registered: March 1991
Senior Member
In article <40civl$neh@korfu.igd.fhg.de>, Tim Purschke <purschke> writes:
> i want to index an array with a number of dimensions that is not known
> until runtime.
> Creation of array:
> a = intarr(dimsize^dimnumber)
> dimidx = intarr(dimnumber) + dimsize
> a = reform(a, dimidx)
>
> Now i want to set an element of a to a certain value.
> eg. a(3,2,4,3) = 7 (for dimnumber = 4)
>
> how can i store this index list to make the asignment work?
> i've tried idx=[3,2,4,3] & a(idx) =7 but this of course does not work.

IDL lets one address multi-dimensional arrays as single-dimension arrays.
Thus, I think this is right:

idx = 3*dimsize^3 + 4*dimsize^2 + 2*dimsize + 3
a(idx) = 7

This can obviously be generalized if your array is not a hypercube, i.e. all of
the dimensions are not the same.

____________________________________________________________
Mark Rivers (312) 702-2279 (office)
CARS (312) 702-9951 (secretary)
Univ. of Chicago (312) 702-5454 (FAX)
5640 S. Ellis Ave. (708) 922-0499 (home)
Chicago, IL 60637 rivers@cars3.uchicago.edu (Internet)
[Message index]
 
Read Message
Previous Topic: 2D DFT Detrending Algorithms [?]
Next Topic: Re: pv-wave, strings-to-function_names

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

Current Time: Thu Oct 09 21:13:14 PDT 2025

Total time taken to generate the page: 0.00536 seconds