Shifts the elements of all vectors along a given dimension of an array. The shift is circular; that is, elements shifted off one end are inserted again at the other end.
Class
Transformational function
Result Value
The result is an array with the same shape and the same data type as ARRAY.
If SHIFT is a scalar, the same shift is applied to each vector. Otherwise, each vector ARRAY (s1, s2, ..., s(DIM-1), :, s(DIM+1), ..., sn) is shifted according to the corresponding value in SHIFT (s1, s2, ..., s(DIM-1), s(DIM+1), ..., sn)
The absolute value of SHIFT determines the amount of shift. The sign of SHIFT determines the direction of the shift:
Examples
! A is the array | A D G |
! | B E H |
! | C F I |
! Shift the first column down one, the second column
! up one, and leave the third column unchanged.
RES = CSHIFT (A, SHIFT = (/-1,1,0/), DIM = 1)
! The result is | C E G |
! | A F H |
! | B D I |
! Do the same shifts as before, but on the rows
! instead of the columns.
RES = CSHIFT (A, SHIFT = (/-1,1,0/), DIM = 2)
! The result is | G A D |
! | E H B |
! | C F I |