XL Fortran for AIX 8.1

Language Reference


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.

is an array of any type.

must be a scalar integer if ARRAY has a rank of one; otherwise, it is a scalar integer or an integer expression of rank rank(ARRAY)-1.

DIM (optional)
is an integer scalar in the range 1 <= DIM <= rank(ARRAY). If absent, it defaults to 1.


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:

Positive SHIFT
moves each element of the vector toward the beginning of the vector.

Negative SHIFT
moves each element of the vector toward the end of the vector.

does no shifting. The value of the vector remains unchanged.


! 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 |

[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]