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

Abstract
I/O
Examples
Particulars
Required Reading
Version
Index_Entries

Abstract


   CSPICE_VALID creates a valid Icy set from a CSPICE Cell of any data type.

   For important details concerning this module's function, please refer to
   the CSPICE routine valid_c.

I/O


   Given:

      size   the scalar integer defining the maximum cardinality (number 
             of elements) of 'set'. 'size' must not exceed the declared size
             of the set's data array.

      n      the scalar integer number of (possibly non-distinct) elements
             initially contained in the set's data array.
             'n' cannot be greater than the size of the set ('size').

      set    a SPICE cell of any data type. 'set' must be declared
             double precision, or integer.

             The user must create 'set' using either cspice_celld 
             or cspice_celli.

   the call:

      cspice_valid, size, n, set

   returns:

      set   on output is a valid set created from the input cell 'set'.

            To create a valid set, the elements are ordered, and
            duplicate elements are removed.  The set's size and
            cardinality members are assigned their correct values.

Examples


   Any numerical results shown for this example may differ between
   platforms as the results depend on the SPICE kernels used as input
   and the machine specific arithmetic implementation.

      ;;
      ;; Create the cell...
      ;;
      SIZE   = 100L
      INISIZ = 10L
      
      ;;
      ;; Create a set call 'a' of size 'SIZE'
      ;;
      a    = cspice_celld( SIZE )
      
      ;;
      ;; Generate a list of double precision values, 0 to INISIZ-1.
      ;; Reverse the order of the list so that in descending order.
      ;;
      list = reverse( dindgen( INISIZ ) )

      ;;
      ;; Add the 'list' data to set 'a'.
      ;;
      cspice_appndd, list, a
      
      for i=0, cspice_card(a)-1 do begin
         print, a.base[ a.data + i]
      endfor 

      ;;
      ;; After the append, does the cell key as a set?
      ;;
      if(  a.isset ) then print, "Cell is a set after append"
      if( ~a.isset ) then print, "Cell is not a set after append"


      ;;
      ;; Validate the cell as a set, ordered elements and
      ;; duplicate elements are removed, ordered as ascending
      ;; value.
      ;;
      cspice_valid, SIZE , INISIZ, a

      ;;
      ;; Output the new set elements
      ;;
      for i=0, cspice_card(a)-1 do begin
         print, a.base[ a.data + i]
      endfor 

      ;;
      ;; After the append, does the cell key as a set?
      ;;
      if(  a.isset ) then print, "Cell is a set after validate."
      if( ~a.isset ) then print, "Cell is not a set after validate."

   IDL outputs:
   
             9.0000000
             8.0000000
             7.0000000
             6.0000000
             5.0000000
             4.0000000
             3.0000000
             2.0000000
             1.0000000
             0.0000000
      
      Check the 'isset' flag, is the cell a set?

         Cell is not a set after append
 
      After the cspice_valid call, output the cell data.
 
             0.0000000
             1.0000000
             2.0000000
             3.0000000
             4.0000000
             5.0000000
             6.0000000
             7.0000000
             8.0000000
             9.0000000

      Again, check the 'isset' flag, is the cell a set after cspice_valid?

         Cell is a set after validate.
         
      confirming the validate operation created a set.


Particulars


   The user must create any needed cell structures with cspice_celld,
   cspice_celli prior to use regardless of whether the routine 
   uses the cell as input or returns it as output.
   

Required Reading


   ICY.REQ
   CELLS.REQ
   SETS.REQ

Version



   -Icy Version 1.1.0, 14-JAN-2009, EDW (JPL)
   
      Corrected code error in Example; replaced a cspice_insrtd call.
      with a cspice_appndd call. Edited argument descriptions in I/O
      section for clarity.

   -Icy Version 1.0.0, 12-SEP-2006, EDW (JPL)

Index_Entries

 
   validate a set
 



Wed Apr  5 17:58:04 2017