CSPICE_INTER calculates the intersection of two sets to form
a third set
For important details concerning this module's function, please refer to
the CSPICE routine inter_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_inter, a, b, c
returns:
c a scalar Icy set, distinct from sets 'a' and 'b', which
contains the intersection of 'a' and 'b' (that is, all of
the elements which are in 'a' AND 'b'). c must have the
same data type as 'a' and 'b'.
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
;; smaller 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 intersection between sets 'a' and 'b', return
;; that intersection to set 'c'.
;;
cspice_inter, 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:
1
3
5
13
The members of 'a' also in 'b'.
The intersection of two sets contains every element
which is in the first set and in the second set.
{a,b} intersect {c,d} = {}
{a,b,c} {b,c,d} {b,c}
{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.0, 18OCT2005, EDW (JPL)
intersection of two sets
