REFORM function changes the dimensions of an array without changing the total number of elements. If no dimensions are specified, REFORM returns a copy of
with all leading dimensions of size 1 removed. If dimensions are specified, the result is given those dimensions. Only the dimensions of
are changed--the actual data remains unmodified.
Result = REFORM(
, ..., D
The array to have its dimensions modified.
The dimensions of the result. The
arguments can be either a single array containing the new dimensions or a sequence of scalar dimensions.
must have the same number of elements as specified by the product of the new dimensions.
Set this keyword to cause the specified dimensions to overwrite the present dimensions of the
parameter. No data are copied, only the internal array descriptor is changed. The result of the function, in this case, is the
parameter with its newly-modified dimensions. For example, to change the dimensions of the variable a, without moving data, enter:
a = REFORM(a, n1, n2, /OVERWRITE)
REFORM can be used to remove "degenerate" leading dimensions of size one. Such dimensions can appear when a subarray is extracted from an array with more dimensions. For example
a = INTARR(10,10,10)
b = a[5,*,*]
HELP, b, REFORM(b)
Executing the above statements produces the output:
B INT = Array[1, 10, 10]
<Expression> INT = Array[10, 10]
b = REFORM(a,200,5)
b = REFORM(a,[200,5])
have identical effect. They create a new array, b, with dimensions of (200, 5), from a.