REFORM

The 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 Array with all leading dimensions of size 1 removed. If dimensions are specified, the result is given those dimensions. Only the dimensions of Array are changed--the actual data remains unmodified.

Calling Sequence

Result = REFORM( Array, D 1 , ..., D n )

Arguments

Array

The array to have its dimensions modified.

D i

The dimensions of the result. The D i arguments can be either a single array containing the new dimensions or a sequence of scalar dimensions. Array must have the same number of elements as specified by the product of the new dimensions.

Keywords

OVERWRITE

Set this keyword to cause the specified dimensions to overwrite the present dimensions of the Array parameter. No data are copied, only the internal array descriptor is changed. The result of the function, in this case, is the Array 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)

Example

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) ; a is a 3-dimensional array.

b = a[5,*,*] ; Extract a "slice" from a.

HELP, b, REFORM(b) ; Use HELP to show what REFORM does.

Executing the above statements produces the output:

B            INT = Array[1, 10, 10]

<Expression> INT = Array[10, 10]

The statements:

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.

See Also

REVERSE , ROT , ROTATE , TRANSPOSE