IDL Reference Guide: Procedures and Functions |

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

*Result* = TRANSPOSE( *Array* [, *P*] )

Returns the reflection of the array along a diagonal.

The array to be transposed.

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 dimensions of *Array* is reversed.

None.

NoteAlso see Transposing Images for a more extensive example. |

Print a simple array and its transpose by entering:

; Create an array: A = INDGEN(3,3) TRANSA = TRANSPOSE(A) ; Print the array and its transpose: PRINT, 'A:' PRINT, A PRINT, 'Transpose of A:' PRINT, TRANSA

IDL prints:

A: 0 1 2 3 4 5 6 7 8 Transpose of A: 0 3 6 1 4 7 2 5 8

This example demonstrates multi-dimensional transposition:

; Create the array: A = INDGEN(2, 3, 4) ; Take the transpose, reversing the order of the indices: B = TRANSPOSE(A) ; 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: C = TRANSPOSE(A, [1, 2, 0]) ; View the sizes of the three arrays: HELP, A, B, C

IDL prints: