## 9.3.133 RESHAPE (SOURCE, SHAPE [, PAD] [, ORDER])

Description: | Constructs an array with a different shape from the argument array.
Class: | Transformational function; Generic
Arguments: | SOURCE | Must be an array (of any data type). It supplies the elements for the result array. Its size must be greater than or equal to PRODUCT(SHAPE) if PAD is omitted or has size zero.
| SHAPE | Must be an integer array of up to 7 elements, with rank one and constant size. It defines the shape of the result array. Its size must be positive; its elements must not have negative values.
| PAD (opt) | Must be an array with the same type and kind parameters as SOURCE. It is used to fill in extra values if the result array is larger than SOURCE.
| ORDER (opt) | Must be an integer array with the same shape as SHAPE. Its elements must be a permutation of (1,2,...,n), where n is the size of SHAPE. If ORDER is omitted, it is assumed to be (1,2,...,n).
Results: | The result is an array of shape SHAPE with the same type and kind parameters as SOURCE. The size of the result is the product of the values of the elements of SHAPE. In the result array, the array elements of SOURCE are placed in the order of dimensions specified by ORDER. If ORDER is omitted, the array elements are placed in normal array element order. The array elements of SOURCE are followed (if necessary) by the array elements of PAD in array element order. If necessary, additional copies of PAD follow until all the elements of the result array have values.

Examples

RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 3/)) has the value

      [ 3  5  7 ]
      [ 4  6  8 ].

RESHAPE ((/3, 4, 5, 6, 7, 8/), (/2, 4/), (/1, 1/), (/2, 1/)) has the value

      [ 3  4  5  6 ]
      [ 7  8  1  1 ].

Previous Page Next Page Table of Contents