[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Arrays: strange feature ?!



In article <3910324B.CDDD96FB@pet.mpin-koeln.mpg.de>,
  Alex Schuster <alex@pet.mpin-koeln.mpg.de> wrote:
> You can create the array like this:
>
> image = [ [image1], [image2], [image3] ]

Not quite.  In fact, the notation is remarkably flexible.

IDL>  i1 = bytarr(10,20)
IDL>  i2 = i1
IDL>  i3 = i1
IDL>  t = [i1,i2,i3]
IDL>  help,t
T               BYTE      = Array[30, 20]
IDL>  t = [[i1],[i2],[i3]]
IDL>  help,t
T               BYTE      = Array[10, 60]
IDL>  t = [[[i1]],[[i2]],[[i3]]]
IDL>  help,t
T               BYTE      = Array[10, 20, 3]
IDL>  t2 = [t,t]
IDL>  help,t2
T2              BYTE      = Array[20, 20, 3]
IDL>  t2 = [[t],[t]]
IDL>  help,t2
T2              BYTE      = Array[10, 40, 3]
IDL>  t2 = [[[t]],[[t]]]
IDL>  help,t2
T2              BYTE      = Array[10, 20, 6]
IDL>  t2 = [[[[t]]],[[[t]]]]

t2 = [[[[t]]],[[[t]]]]
                      ^
% Only eight levels of variable concatenation are allowed.
IDL>

As you can see, there is a limit.  For three or fewer
dimensions, the rule seems to be that if the number of
outermost brackets in a row is 1, the arrays are
concatenated in X; if 2, they are concatenated in Y; and
if 3, they are concatenated in Z.  Consider this further
example:

IDL>  x = indgen(10)
IDL>  help, [[[x]],[[x]],[[x]]]
<Expression>    INT       = Array[10, 1, 3]

YMMV, but I like it, myself.

      Bob Hill

--
 Robert S. Hill
 Raytheon ITSS       Code 681, NASA/GSFC, Greenbelt, MD 20771



Sent via Deja.com http://www.deja.com/
Before you buy.