REVERSE Function
Standard Library function that reverses a vector or array for a given dimension.
enabled.
Usage
result = REVERSE(array, [dimension])
Input Parameters
array—The vector or array to be reversed.
dimension—(optional) An integer specifying which dimension of array to reverse. By default, the 0th dimension is reversed.
Note: |
The dimension argument breaks with PV-WAVE convention of 0-based indexing and is instead 1-based. That is, the 0th dimension of an array is specified by a 1 and the first dimension by a 2. |
Returned Value
result—The vector or array that has been reversed.
Keywords
None.
Example 1
This example exhibits the result of applying REVERSE to a 4‑by‑3 integer array.
; Create a 4-by-3 integer array. Each element has a value equal
; to its one-dimensional subscript.
a = INDGEN(4, 3)
PRINT, a
; PV-WAVE prints:
; 0 1 2 3
; 4 5 6 7
; 8 9 10 11
; Reverse the rows of a.
PRINT, REVERSE(a)
; PV-WAVE prints:
; 3 2 1 0
; 7 6 5 4
; 11 10 9 8
; Reverse the columns of a.
PRINT, REVERSE(a, 2)
; PV-WAVE prints:
; 8 9 10 11
; 4 5 6 7
; 0 1 2 3
; Reverse the columns and rows of a.
PRINT, REVERSE(REVERSE(a), 2)
; PV-WAVE prints:
; 11 10 9 8
; 7 6 5 4
; 3 2 1 0
Example 2
The following commands first display the image contained in the scientist3.dat file, and then rotate and redisplay it:
image1 = BYTARR(250, 200)
OPENR, unit, !Data_dir + 'scientist3.dat', /Get_lun
READU, unit, image1
FREE_LUN, unit
WINDOW, Xsize=500, Ysize=200
TV, image1, 0
TV, REVERSE(image1), 1