The
TRANSPOSE function returns the transpose of *
Array*
. If an optional permutation vector is provided, the dimensions of *
Array*
are rearranged as well.

A vector specifying how the dimensions of *
Array*
will be permuted. The elements of *
P*
correspond to the dimensions of *
Array*
; the *
i*
th dimension of the output array is dimension *
P*
[*
i*
] of the input array. Each element of the vector *
P*
must be unique. Dimensions start at zero and can not be repeated.

If *
P*
is not present, the order of the indices of *
Array*
is reversed.

Print a simple array and its transpose by entering:

IDL prints the original array:

To see how a multi-dimensional transposition works, first create a three-dimensional array A:

Take the transpose, reversing the order of the indices:

Now re-order the dimensions of A, so that the second dimension becomes the first, the third becomes the second, and the first becomes the third:

Now view the sizes of the three arrays:

A INT = Array[2, 3, 4] *;
The original array.*

B INT = Array[4, 3, 2] *;
Original array with indices reversed.*

C INT = Array[3, 4, 2] *;
Original array with indices re-ordered.*