Re: behavior of arrays [message #15430] |
Wed, 19 May 1999 00:00 |
Pavel Romashkin
Messages: 166 Registered: April 1999
|
Senior Member |
|
|
I do not quite realize what is the point in this exercise. FLTARR(10,1)
is an array with 10 columns and 1 row (which all is meaningful only in
the direction of array operations which in IDL is row-wise). Therefore,
seems to me that FLTARR(10, 1) is the same as FLTARR(10) to begin with
(unlike FLTARR(1, 10)). If you anticipate expanding the matrix, its easy
to do by using TRANSPOSE and subscripts. I have never experienced a
problem with losing or mixing up dimensions, although most of my data
are matrices. In the example below, I see no loss of information in the
transition from d to c. If you defined more than 1 row, C would be 2D
in the last statement.
Cheers,
Pavel
"R.Bauer" wrote:
> I have some problems to understand the logic which may be behind the
> handling of an array
> like defined.
>
> Why is the result help, b.d only [10] and not [10,1] ?
>
> This means I will lose the information that's it is / was a 2-dim
> dataset.
>
> R.Bauer
>
> d=reform(findgen(10),10,1)
> help,d
> ;D FLOAT = Array[10, 1]
>
> b=create_struct('d',d)
> help,b,/str
>
> ;** Structure <1348428>, 1 tags, length=40, refs=1:
> ; D FLOAT Array[10, 1]
>
> help,b.d
> ; <Expression> FLOAT = Array[10]
>
> c=b.d
> help,c
> ; C FLOAT = Array[10]
|
|
|
Re: behavior of arrays [message #15431 is a reply to message #15430] |
Wed, 19 May 1999 00:00  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
Don't get me started on this again. You can find my recent tirade on
this subject under "dropped dimensions" on dejanews.com.
For the case of your structure, I think that b.d is *actually* still a
10x1 array, but any access to it will cause IDL to automatically
collapse the degenerate dimension in the expression. Therefore, even
HELP thinks that it is a 10-vector, not a 10x1 array.
Practically speaking, you will need to REFORM() your array whenever
you need to use it.
Craig
"R.Bauer" <R.Bauer@fz-juelich.de> writes:
>
> I have some problems to understand the logic which may be behind the
> handling of an array
> like defined.
>
> Why is the result help, b.d only [10] and not [10,1] ?
>
> This means I will lose the information that's it is / was a 2-dim
> dataset.
...
> d=reform(findgen(10),10,1)
> help,d
> ;D FLOAT = Array[10, 1]
>
> b=create_struct('d',d)
> help,b,/str
>
> ;** Structure <1348428>, 1 tags, length=40, refs=1:
> ; D FLOAT Array[10, 1]
>
>
> help,b.d
> ; <Expression> FLOAT = Array[10]
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@astrog.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|