Library /sys$common/syshlp/helplib.hlb  —  FORTRAN  Intrinsic Procedures, CSHIFT
  CSHIFT (array, shift [,dim])

  Class:  Transformational function - Generic

  Performs a circular shift on a rank-one array, or performs circular
  shifts on all the complete rank-one sections along a given
  dimension of an array of rank two or greater.

  Elements shifted off one end are inserted at the other end.
  Different sections can be shifted by different amounts and in
  different directions.

  The "shift" can be a scalar integer or array with rank one less
  than "array".  The "dim" must be a scalar integer with a value in
  the range 1 to n, where "n" is the rank of "array".  If "dim" is
  omitted, it is assumed to be 1.

  The result is an array with the same type, type parameters, and
  shape as "array".

  If "array" has rank one, element i of the result is array (1 +
  MODULO (i + "shift" - 1, SIZE (array))).

  If "array" has rank greater than 1, section (s1, s2, ...s"dim"-1,
  :, s"dim"+1, ..., sn) of the result has a value equal to CSHIFT
  (array(s1, s2, ..., s"dim"-1, :, s"dim"+1, ..., sn), sh, 1), where
  "sh" is "shift" or shift(s1, s2, ..., s"dim"-1, s"dim"+1,..., sn).

  The value of "shift" determines the amount and direction of the
  circular shift.  A positive integer causes a shift to the left (in
  rows) or up (in columns).  A negative integer causes a shift to the
  right (in rows) or down (in columns).

  Examples:

  V is the array (1, 2, 3, 4, 5, 6).

  CSHIFT (V, SHIFT=2) shifts V circularly to the left by 2 positions,
  producing the value (3, 4, 5, 6, 1, 2).

  CSHIFT (V, SHIFT= -2) shifts V circularly to the right by 2
  positions, producing the value (5, 6, 1, 2, 3, 4).

  M is the array Consider the following array:

    Array M

    |1 2 3|
    |4 5 6|
    |7 8 9|

  CSHIFT (M, SHIFT = 1, DIM = 2) produces the result:

    |2 3 1|
    |5 6 4|
    |8 9 7|

  CSHIFT (M, SHIFT = -1, DIM = 1) produces the result

    |7 8 9|
    |1 2 3|
    |4 5 6|

  CSHIFT (M, SHIFT = (/1, -1, 0/), DIM = 2) produces the result

    |2 3 1|
    |6 4 5|
    |7 8 9|
Close Help