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

Home » Public Forums » archive » Re: IDL data structures question
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: IDL data structures question [message #1398] Tue, 05 October 1993 18:24 Go to previous message
jennifer is currently offline  jennifer
Messages: 8
Registered: October 1991
Junior Member
I posted a question about data structures a couple
of weeks ago. Thank you Scott, Joel and Bill for
your answers, which I have enclose for others' interest.
I ended up using Scott's solution, though I think Joel's
and Bill's would work too.

> From: jennifer@gaia.arc.nasa.gov (Jennifer Dungan)
> Subject:IDL data structures question
> Date: Wed, 22 Sep 1993 22:57:51 GMT
> Message-ID:<1993Sep22.225751.18825@news.arc.nasa.gov>

> I wonder if someone could help me with a programming problem. In IDL or PV-Wave,
> is it possible to create a data structure that has two dimensions, one containing
> an integer scalar, the other containing a vector _of variable length_? Basically,
> I want to be able to index some vectors, which are of various lengths, so I can loop
> through them. Seems to me I should be able to use structures somehow to create
> pointers, but I can't seem to figure it out.
>
> Any pointers (no pun intended) will be appreciated.
>
>
> Jennifer Dungan | MS 242-4
> Research Scientist | NASA Ames Research Center
> JCWS, Inc. Tel. (415) 604-3618 | Moffett Field, CA 94035-1000
> email: dungan@gaia.arc.nasa.gov | USA

If I understand correctly what you would like to do, here is a method that
I have used. Define a matrix

A = FLTARR(N,M)

where N is the dimension of the longest vector and M is the number of vectors.
Then define a vector LEN to hold the length of each vector

LEN = INTARR(M)

Whenever vectors are extracted from A, LEN is used to get the correct
number of elements.

I realize that this method wastes storage space for the smaller vectors, but
storage is often not a problem. Does this answer your question, or were you
thinking of something more complicated?

--Scott Claflin

-- -- -- -- -- -- -- -- -- -- -- --

Jennifer,
I've looked into the problem. I'm sorry to say that as far
as I can tell, you can't get there from here. If someone let you know
how to set this up, please let me know as I'd love to find out how to
do it myself.

There may be way around the problem, which is to create an unnamed structure,
like this
a = {x : my_integer, y : my_vector}

Each time you need a different-length vector for y, you create a new
structure...

b = {x : Another_int, y : Another_vect}

etc etc. This way, you can create a bunch of different structures, each of
which has its own y-vector length, which is in the end probably what you want.

Good luck,

Joel


-- -- -- -- -- -- -- -- -- -- -- --

In IDL you can use anonymous structures to do this. For example:

IDL> MYSTRUC = {MYTAG1: SCALAR_VARIABLE, $
MYTAG2: ARRAY_VARIABLE}

Since the structure doesn't have a name, you can create as many of them as you
want on the fly, each one with a different array size. The only restriction is
that one can't have an anonymous structure within another structure. (Please,
please, please RSI remove this restriction. :^) ).

Bill Thompson
[Message index]
 
Read Message
Read Message
Previous Topic: Re: RSI response to CONTOUR problems/questions.
Next Topic: FITS data format

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

Current Time: Sat Oct 11 02:53:13 PDT 2025

Total time taken to generate the page: 0.16405 seconds