REVERSE

The REVERSE function reverses the order of rows or columns in a one-, two-, or three-dimensional array.

This routine is written in the IDL language. Its source code can be found in the file reverse.pro in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = REVERSE( Array [, Subscript_Index] )

Arguments

Array

The array containing the original data.

Subscript_Index

If this parameter is omitted or 1, the first subscript is reversed (i.e., columns are reversed). Set this parameter to 2 to reverse rows. Set this parameter to 3 to reverse around the third dimension of the array. This argument must be present if Array is three dimensional.

Example

Reverse the order of an array where each element is set to the value of its subscript:

A = [[0,1,2],[3,4,5],[6,7,8]] ; Create an array.

PRINT, A ; Print the array.

IDL prints:

0 1 2

3 4 5

6 7 8

PRINT, REVERSE(A) ; Reverse the columns of A.

IDL prints:

2 1 0

5 4 3

8 7 6

PRINT, REVERSE(A, 2) ; Reverse the rows of A.

IDL prints:

6 7 8

3 4 5

0 1 2

See Also

INVERT , REFORM , ROT , ROTATE , SHIFT , TRANSPOSE