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.
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 nondistinct) 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.
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 INISIZ1.
;; 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.
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.
ICY.REQ
CELLS.REQ
SETS.REQ
Icy Version 1.1.0, 14JAN2009, 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, 12SEP2006, EDW (JPL)
validate a set
