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
isordv

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

     ISORDV ( Is it an order vector )

     LOGICAL FUNCTION ISORDV ( ARRAY, N )

Abstract

     Determine whether an array of N items contains the integers
     1 through N.

Required_Reading

     None.

Keywords

     SEARCH
     SORT
     UTILITY

Declarations

     IMPLICIT NONE

     INTEGER               ARRAY (*)
     INTEGER               N

Brief_I/O

     VARIABLE  I/O  DESCRIPTION
     --------  ---  --------------------------------------------------
     ARRAY      I   Array of integers.
     N          I   Number of integers in ARRAY.

     The function returns .TRUE. if the array contains the integers
     1 through N, otherwise it returns .FALSE.

Detailed_Input

     ARRAY    is an array of integers. Often this will be an array
              that is a candidate order vector to be passed to
              a routine for re-ordering some parallel array.

     N        is the number of elements in ARRAY.

Detailed_Output

     The function returns .TRUE. if the array contains the integers
     1 through N. Otherwise it returns .FALSE.

Parameters

     None.

Exceptions

     Error free.

     1)  If N < 1, the function returns .FALSE.

Files

     None.

Particulars

     This function provides a simple means of determining whether
     or not an array of N integers contains exactly the integers
     1 through N.

Examples

     1) Suppose you wished to reorder an array of strings based upon
        a ranking array supplied by a user. If the ranking array
        contains any duplicates or refers to indices that are out
        of the range of valid indices for the array of strings,
        the attempt to reorder the array of strings cannot succeed.
        Its usually better to detect such a possibility before
        you begin trying to reorder the array of strings. This routine
        will detect the error.

        The block of code below illustrates this idea.


           IF ( ISORDV ( ORDVEC, N ) ) THEN

              ...reorder the input array of strings

              CALL REORDC ( ORDVEC, N, STRNGS )

           ELSE

              ...state the problem and let the user decide what
              to do about it.
                    .
                    .
                    .

           END IF


     2) This routine can also be used to determine whether or not an
        array contains every integer between K and N (where K < N ).


           First subtract K-1 from each integer

           DO I = 1, N-K+1
              ARRAY(I) = ARRAY(I) - K + 1
           END DO

           See if the modified array is an order vector

           OK = ISORDV ( ARRAY, N-K )

           Return the array to its original state.

           DO I = 1, N-K+1
              ARRAY(I) = ARRAY(I) + K - 1
           END DO

Restrictions

     None.

Literature_References

     None.

Author_and_Institution

     N.J. Bachman       (JPL)
     J. Diaz del Rio    (ODC Space)
     W.L. Taber         (JPL)
     I.M. Underwood     (JPL)

Version

    SPICELIB Version 1.1.0, 03-JUL-2021 (JDR)

        Added IMPLICIT NONE statement.

        Edited the header to comply with NAIF standard.

    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, 06-MAR-1991 (NJB) (WLT) (IMU)
Fri Dec 31 18:36:28 2021