Index of Functions: A  B  C  D  E  F  G  H  I  J  K  L  M  N  O  P  Q  R  S  T  U  V  W  X 
Index Page
cyclai

Table of contents
Procedure
Abstract
Required_Reading
Keywords
Declarations
Brief_I/O
Detailed_Input
Detailed_Output
Parameters
Exceptions
Files
Particulars
Examples
Restrictions
Literature_References
Author_and_Institution
Version

Procedure

     CYCLAI ( Cycle the elements of an integer array )

     SUBROUTINE CYCLAI ( ARRAY, NELT, DIR, NCYCLE, OUT )

Abstract

     Cycle the elements of an integer array forward or backward.

Required_Reading

     None.

Keywords

     ARRAY

Declarations

     IMPLICIT NONE

     INTEGER               ARRAY    ( * )
     INTEGER               NELT
     CHARACTER*1           DIR
     INTEGER               NCYCLE
     INTEGER               OUT      ( * )

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     ARRAY      I   Input array.
     NELT       I   Number of elements.
     DIR        I   Direction to cycle: 'F' or 'B'.
     NCYCLE     I   Number of times to cycle.
     OUT        O   Cycled array.

Detailed_Input

     ARRAY    is the array to be cycled.

     NELT     is the number of elements in the input array.

     DIR      is the direction in which the elements in the
              array are to be cycled.

                 'F' or 'f'  to cycle forward.
                 'B' or 'b'  to cycle backward.

     NCYCLE   is the number of times the elements in the array
              are to be cycled.

Detailed_Output

     OUT      is the input array after it has been cycled.

Parameters

     None.

Exceptions

     1)  If the value of DIR is not recognized, the error
         SPICE(INVALIDDIRECTION) is signaled.

     2)  If NELT is less than 1, the output array is not modified.

     3)  If NCYCLE is negative, the array is cycled NCYCLE times in
         the opposite direction of DIR.

Files

     None.

Particulars

     An array is cycled when its contents are shifted forward or
     backward by one place. An element pushed off one end of the
     array is brought around to the other end of the array instead
     of disappearing.

Examples

     Let the integer array A contain the following elements.

        A(1) = 1
        A(2) = 2
        A(3) = 3
        A(4) = 4

     Cycling A forward once yields the array

        A(1) = 4
        A(2) = 1
        A(3) = 2
        A(4) = 3

     Cycling A backward once yields the array

        A(1) = 2
        A(2) = 3
        A(3) = 4
        A(4) = 1

     Cycling by any multiple of the number of elements in the array
     yields the same array.

Restrictions

     1)  The memory used for the output array must be disjoint from the
         memory used for the input array.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     H.A. Neilan        (JPL)
     B.V. Semenov       (JPL)
     W.L. Taber         (JPL)
     I.M. Underwood     (JPL)

Version

    SPICELIB Version 1.1.0, 20-AUG-2021 (JDR)

        Added IMPLICIT NONE statement.

        Edited the header to comply with NAIF standard.

    SPICELIB Version 1.0.3, 18-MAY-2010 (BVS)

        Removed "C$" marker from text in the header.

    SPICELIB Version 1.0.2, 23-APR-2010 (NJB)

        Header correction: assertions that the output
        can overwrite the input have been removed.

    SPICELIB Version 1.0.1, 10-MAR-1992 (WLT)

        Comment section for permuted index source lines was added
        following the header.

    SPICELIB Version 1.0.0, 31-JAN-1990 (IMU) (WLT) (HAN)
Fri Dec 31 18:36:06 2021