RESHAPE intrinsic function
Standard: F77 F90 F95 F2003 F2008
  Example Program


SOURCE : array of any type;
SHAPE : Integer array with rank 1 and constant shape, 1≤SIZE(SHAPE)≤7;
PAD : array with the same type and type parameters as SOURCE;
ORDER : Integer array with rank 1, SIZE(ORDER)=SIZE(SHAPE);

Result : same type and type parameters as SOURCE, with shape SHAPE.


If the ORDER argument is not present, the result is the array with shape SHAPE whose elements, in array element order, are the same as SOURCE; if SIZE(SOURCE)<PRODUCT(SHAPE), additional values are taken from PAD in array element order (repeatedly, if SIZE(SOURCE)+SIZE(PAD)<PRODUCT(SHAPE)).

If PAD is not present, or SIZE(PAD)=0, SIZE(SOURCE) must be greater than or equal to PRODUCT(SHAPE).

If ORDER is present, it must be a permutation vector with values [ 1 ... SIZE(SHAPE) ]. It specifies a multi-dimensional transposition that is applied to SOURCE before using its elements in the result. That is, the elements of A are taken in permuted subscript order ORDER(1), ... ORDER(rank of A). For example, if A is a 2-dimensional array,

  RESHAPE (A, [ SIZE(A,2),SIZE(A,1) ], ORDER = [ 2, 1 ] )
is equal to TRANSPOSE(A).

ORDER has no effect on the interpretation of the elements of PAD, which are always taken in array element order.

SPREAD intrinsic function, TRANSPOSE intrinsic function.