Re: REFORM: new subscripts must not change the number elements in array [message #90415 is a reply to message #90413] |
Mon, 02 March 2015 07:31   |
Helder Marchetto
Messages: 520 Registered: November 2011
|
Senior Member |
|
|
On Monday, March 2, 2015 at 4:19:32 PM UTC+1, g.na...@gmail.com wrote:
> I have a 2D array of A=[200,200]
>
> I am running REFORM but get the following error
> "REFORM: New subscripts must not change the number elements in A"
>
> This is what I am doing
> A = reform(A, 100L, 200L*200L, /overwrite)
>
> Why isn't it working?
Because 4000 is not 4000000.
Let me show:
IDL> A=randomu(s,200,200)
IDL> print, product(size(a, /dimensions), /preserve_type)
40000
IDL> print, product([100L, 200L*200L], /preserve_type)
4000000
If your array is has 200 x 200 elements, the total is 40000.
Now with reform you want to make it 100 x (200x200)... this is 4000000.
Maybe (maybe!) what you want is:
a = reform(a, 100l, 200l*2l, /overwrite)
Cheers,
Helder
|
|
|