Index Page reordd_c

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

Procedure Abstract Required_Reading Keywords Brief_I/O Detailed_Input | Detailed_Output Parameters Exceptions Files Particulars Examples | Restrictions Literature_References Author_and_Institution Version Index_Entries

#### Procedure

       void reordd_c ( ConstSpiceInt      * iorder,
                       SpiceInt             ndim,
                       SpiceDouble        * array  )

#### Abstract

       Re-order the elements of a double precision array according to
       a given order vector.

#### Required_Reading

       None.

#### Keywords

        ARRAY,  SORT

#### Brief_I/O

       VARIABLE  I/O  DESCRIPTION
       --------  ---  --------------------------------------------------
       iorder     I   Order vector to be used to re-order array.
       ndim       I   Dimension of array.
       array     I/O  Array to be re-ordered.

#### Detailed_Input

       iorder      is the order vector to be used to re-order the input
                   array. The first element of iorder is the index of
                   the first item of the re-ordered array, and so on.

                   Note that the order imposed by reordd_c is not the
                   same order that would be imposed by a sorting
                   routine. In general, the order vector will have
                   been created (by one of the order routines) for
                   a related array, as illustrated in the example below.

       ndim        is the number of elements in the input array.

       array       on input, is an array containing some number of
                   elements in unspecified order.

#### Detailed_Output

       array       on output, is the same array, with the elements
                   in re-ordered as specified by iorder.

#### Parameters

       None.

#### Exceptions

       1) If memory cannot be allocated to create a Fortran-style version of
          the input order vector, the error SPICE(MALLOCFAILED) is signaled.

       2) If ndim < 2, this routine executes a no-op.  This case is
          not an error.

#### Files

       None.

#### Particulars

       reordd_c uses a cyclical algorithm to re-order the elements of
       the array in place. After re-ordering, element iorder[0] of
       the input array is the first element of the output array,
       element iorder[1] is the input array is the second element of
       the output array, and so on.

       The order vector used by reordd_c is typically created for
       a related array by one of the order routines, as shown in
       the example below.

#### Examples

       In the following example, the ORDER and REORD routines are
       used to sort four related arrays (containing the names,
       masses, integer ID codes, and visual magnitudes for a group
       of satellites). This is representative of the typical use of
       these routines.

          #include "SpiceUsr.h"
              .
              .
              .
          /.
          Sort the object arrays by name.
          ./

          orderc_c ( namlen, names, n,  iorder );

          reordc_c ( iorder, n, namlen, names  );
          reordd_c ( iorder, n,         masses );
          reordi_c ( iorder, n,         codes  );
          reordd_c ( iorder, n,         vmags  );

#### Restrictions

       None.

#### Literature_References

        None.

#### Author_and_Institution

       N.J. Bachman    (JPL)
       W.L. Taber      (JPL)
       I.M. Underwood  (JPL)

#### Version

       -CSPICE Version 1.0.0, 11-JAN-2003 (EDW)

          Trivial. Corrected 'Detailed_output' section
          header to 'Detailed_Output'.

       -CSPICE Version 1.0.0, 10-JUL-2002 (NJB)

#### Index_Entries

       reorder a d.p. array

#### Link to routine reordd_c source file reordd_c.c

    Wed Apr  5 17:54:41 2017