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

Home » Public Forums » archive » ARRAY OF 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: Array of arrays [message #47707 is a reply to message #12759] Thu, 23 February 2006 08:53 Go to previous messageGo to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Fritz writes:

> One (hopefully) last question...
>
> I have the following code:
>
> nb_classes = 3
> references = ptrarr(nb_classes)
> for i=0, nb_classes-1 do begin
> nb_samples = 5
> list_samples = ptrarr(nb_samples)
> for j=0, nb_samples-1 do begin
> data = indgen(21,19,4)
> list_samples[j] = ptr_New(data)
> endfor
> references[i] = ptr_new(list_samples)
> endfor
>
> This code is simplified because for each class, the number of samples may
> vary and also the size of data.
>
> The question is:
> How do I retrieve the data, let say, for sample 3 of class 2 ?
>
> In the previous example,
>> t = PtrArr(3)
>> t[0] = Ptr_New(intarr(2,5,4))
>> t[1] = Ptr_New(intarr(6,5,4))
>> t[2] = Ptr_New(intarr(7,8,4))
>
> (*t[1]) allows to acces the second element
> (*t[1])[*,*,2] allows to acces the third band of the second element.
>
> But in the code above ?
> I tried
>> dat = (*references[0])[(*liste_samples[1])]
> but dat is not the same as data.
>
> Fran�ois, who spend much time on something that may appear very simple to
> others...

Oh, well, we are not going to embarrass ourselves by
explaining how long it takes us to understand things.
That's why there is 24 hours in every day, after all. :-)

I would access the data in the third sample in class 2 like this:

IDL> Help, *(*references[1])[2]

It will help to remember that the * operator has a lower order
of precedence than almost any other operator. So references[1]
is a reference to a pointer in the pointer array, and *references[1]
de-references that pointer, which is also a reference to a pointer
array, so (*references[1])[2] is a reference to a pointer in
*that* pointer array, and *(*references[1])[2] de-references that
pointer.

You might find these articles worth re-reading:

http://www.dfanning.com/misc_tips/precedence.html
http://www.dfanning.com/misc_tips/pointers.html

Cheers,

David





--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: iVolume isosurface placement
Next Topic: Re: flux-conserving image resampling?

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

Current Time: Sun Oct 12 04:23:23 PDT 2025

Total time taken to generate the page: 1.35882 seconds