void union_c ( SpiceCell * a,
SpiceCell * b,
SpiceCell * c )
Compute the union of two sets of any data type to form a third set.
SETS
CELLS, SETS
VARIABLE I/O DESCRIPTION
-------- --- --------------------------------------------------
a I First input set.
b I Second input set.
c O Union of a and b.
a is a CSPICE set. a must be declared as a SpiceCell
of data type character, double precision, or integer.
b is a CSPICE set, distinct from a. b must have the
same data type as a.
c is a CSPICE set, distinct from sets a and b, which
contains the union of a and b (that is, all of
the elements which are in a or b or both). c must
have the same data type as a and b.
When comparing elements of character sets, this routine
ignores trailing blanks. Trailing blanks will be
trimmed from the members of the output set c.
None.
1) If the input set arguments don't have identical data types,
the error SPICE(TYPEMISMATCH) is signaled.
2) If the union of the two sets contains more elements than can be
contained in the output set, the error SPICE(SETEXCESS) is signaled.
3) If the set arguments have character type and the length of the
elements of the output set is less than the maximum of the
lengths of the elements of the input sets, the error
SPICE(ELEMENTSTOOSHORT) is signaled.
4) If either of the input arguments may be unordered or contain
duplicates, the error SPICE(NOTASET) is signaled.
None.
This is a generic CSPICE set routine; it operates on sets of any
supported data type.
The union of two sets contains every element which is
in the first set, or in the second set, or in both sets.
{a,b} union {c,d} = {a,b,c,d}
{a,b,c} {b,c,d} {a,b,c,d}
{a,b,c,d} {} {a,b,c,d}
{} {a,b,c,d} {a,b,c,d}
{} {} {}
1) The following code fragment places the union of the character sets
planets and asteroids into the character set result.
#include "SpiceUsr.h"
.
.
.
/.
Declare the sets with string length NAMLEN and with maximum
number of elements MAXSIZ.
./
SPICECHAR_CELL ( planets, MAXSIZ, NAMLEN );
SPICECHAR_CELL ( asteroids, MAXSIZ, NAMLEN );
SPICECHAR_CELL ( result, MAXSIZ, NAMLEN );
.
.
.
/.
Compute the union.
./
union_c ( &planets, &asteroids, &result );
2) Repeat example #1, this time using integer sets containing
ID codes of the bodies of interest.
#include "SpiceUsr.h"
.
.
.
/.
Declare the sets with maximum number of elements MAXSIZ.
./
SPICEINT_CELL ( planets, MAXSIZ );
SPICEINT_CELL ( asteroids, MAXSIZ );
SPICEINT_CELL ( result, MAXSIZ );
.
.
.
/.
Compute the union.
./
union_c ( &planets, &asteroids, &result );
3) Construct a set containing the periapse and apoapse TDB epochs
of an orbiter, given two separate sets containing the epochs of
those events.
#include "SpiceUsr.h"
.
.
.
/.
Declare the sets with maximum number of elements MAXSIZ.
./
SPICEDOUBLE_CELL ( periapse, MAXSIZ );
SPICEDOUBLE_CELL ( apoapse, MAXSIZ );
SPICEDOUBLE_CELL ( result, MAXSIZ );
.
.
.
/.
Compute the union.
./
union_c ( &periapse, &apoapse, &result );
1) The output set must be distinct from both of the input sets.
For example, the following calls are invalid.
union_c ( ¤t, &new, ¤t );
union_c ( &new, ¤t, ¤t );
In each of the examples above, whether or not the subroutine
signals an error, the results will almost certainly be wrong.
Nearly the same effect can be achieved, however, by placing the
result into a temporary set, which is immediately copied back
into one of the input sets, as shown below.
union_c ( ¤t, &new, &temp );
copy_c ( &temp, &new );
2) String comparisons performed by this routine are Fortran-style:
trailing blanks in the input sets are ignored. This gives
consistent behavior with CSPICE code generated by the f2c
translator, as well as with the Fortran SPICE Toolkit.
Note that this behavior is not identical to that of the ANSI
C library functions strcmp and strncmp.
None.
N.J. Bachman (JPL)
C.A. Curzon (JPL)
W.L. Taber (JPL)
I.M. Underwood (JPL)
-CSPICE Version 1.1.0, 15-FEB-2005 (NJB)
Bug fix: loop bound changed from 2 to 3 in loop used
to free dynamically allocated arrays.
-CSPICE Version 1.0.0, 08-AUG-2002 (NJB) (CAC) (WLT) (IMU)
union of two sets
Link to routine union_c source file union_c.c
|