CSPICE_DIFF takes the symmetric difference of two sets of any data type
to form a third set.
For important details concerning this module's function, please refer to
the CSPICE routine sdiff_c.
Given:
a,
b scalar Icy sets, each of the same type, double precision
or integer.
The user must create 'a' and 'b' using either
cspice_celld, or cspice_celli.
the call:
cspice_diff, a, b, c
returns:
c is an Icy set, distinct from sets 'a' and 'b' but with
the same type, containing the difference of 'a' and 'b'
(that is, all of the elements which are in 'a' or
'b' but NOT both).
The user must create 'c' using either cspice_celld
or cspice_celli.
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 three cells with the necessary size.
;; Set 'c' need not have a larger size than the
;; larger of 'a' or 'b'.
;;
SIZE = 10
a = cspice_celli( SIZE )
b = cspice_celli( SIZE )
c = cspice_celli( SIZE )
;;
;; Create vectors of integers. It is more efficient to
;; load a set from a vector than looping over the
;; call, inserting one 'item' per iteration.
;;
ints1 = [ 0, 1, 1, 2, 3, 5, 8, 13 ]
ints2 = [ 1, 3, 5, 7, 11, 13]
;;
;; Insert the 'ints1' list into set 'a', 'ints2 '
;; into set 'b'.
;;
cspice_insrti, ints1, a
cspice_insrti, ints2, b
;;
;; Calculate the symmetric difference between sets ,
;; 'a' and 'b' return that difference to set 'c'.
;;
cspice_sdiff, a, b, c
;;
;; Output the contents of set 'c'. Recall
;; set data begins at 'c.base[ c.data + 0 ]'.
;;
for i=0, cspice_card(c)1 do begin
print, c.base[ c.data + i]
endfor
IDL outputs:
0
2
7
8
11
The members of 'a' and 'b' not in both 'a' and 'b'.
The symmetric difference of two sets contains every element which is
in the first set OR in the second set, but NOT in both sets.
{a,b} sym. difference {c,d} = {a,b,c,d}
{a,b,c} {b,c,d} {a,d}
{a,b,c,d} {} {a,b,c,d}
{} {a,b,c,d} {a,b,c,d}
{} {} {}
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.0.1, 28SEP2006, EDW (JPL)
Corrections to English.
Correct Required Reading citation CELL.REQ to CELLS.REQ.
Icy Version 1.0.0, 21FEB2005, EDW (JPL)
symmetric difference of two sets
