1 /* 2 3 -Procedure elemd_c ( Element of a double precision set ) 4 5 -Abstract 6 7 Determine whether an item is an element of a double precision set. 8 9 -Disclaimer 10 11 THIS SOFTWARE AND ANY RELATED MATERIALS WERE CREATED BY THE 12 CALIFORNIA INSTITUTE OF TECHNOLOGY (CALTECH) UNDER A U.S. 13 GOVERNMENT CONTRACT WITH THE NATIONAL AERONAUTICS AND SPACE 14 ADMINISTRATION (NASA). THE SOFTWARE IS TECHNOLOGY AND SOFTWARE 15 PUBLICLY AVAILABLE UNDER U.S. EXPORT LAWS AND IS PROVIDED "AS-IS" 16 TO THE RECIPIENT WITHOUT WARRANTY OF ANY KIND, INCLUDING ANY 17 WARRANTIES OF PERFORMANCE OR MERCHANTABILITY OR FITNESS FOR A 18 PARTICULAR USE OR PURPOSE (AS SET FORTH IN UNITED STATES UCC 19 SECTIONS 2312-2313) OR FOR ANY PURPOSE WHATSOEVER, FOR THE 20 SOFTWARE AND RELATED MATERIALS, HOWEVER USED. 21 22 IN NO EVENT SHALL CALTECH, ITS JET PROPULSION LABORATORY, OR NASA 23 BE LIABLE FOR ANY DAMAGES AND/OR COSTS, INCLUDING, BUT NOT 24 LIMITED TO, INCIDENTAL OR CONSEQUENTIAL DAMAGES OF ANY KIND, 25 INCLUDING ECONOMIC DAMAGE OR INJURY TO PROPERTY AND LOST PROFITS, 26 REGARDLESS OF WHETHER CALTECH, JPL, OR NASA BE ADVISED, HAVE 27 REASON TO KNOW, OR, IN FACT, SHALL KNOW OF THE POSSIBILITY. 28 29 RECIPIENT BEARS ALL RISK RELATING TO QUALITY AND PERFORMANCE OF 30 THE SOFTWARE AND ANY RELATED MATERIALS, AND AGREES TO INDEMNIFY 31 CALTECH AND NASA FOR ALL THIRD-PARTY CLAIMS RESULTING FROM THE 32 ACTIONS OF RECIPIENT IN THE USE OF THE SOFTWARE. 33 34 -Required_Reading 35 36 SETS 37 38 -Keywords 39 40 CELLS, SETS 41 42 */ 43 44 #include "SpiceUsr.h" 45 #include "SpiceZfc.h" 46 #include "SpiceZmc.h" 47 48 elemd_c(SpiceDouble item,SpiceCell * set)49 SpiceBoolean elemd_c ( SpiceDouble item, 50 SpiceCell * set ) 51 52 /* 53 54 -Brief_I/O 55 56 VARIABLE I/O DESCRIPTION 57 -------- --- -------------------------------------------------- 58 item I Item to be tested. 59 set I Set to be tested. 60 61 The function returns SPICETRUE if item is an element of set. 62 63 -Detailed_Input 64 65 item is an item which may or may not be an element of 66 the input set. 67 68 69 set is a CSPICE set. set must be declared as a double 70 precision SpiceCell. 71 72 -Detailed_Output 73 74 The function returns SPICETRUE if item is a member of the set, 75 and returns SPICEFALSE otherwise. 76 77 -Parameters 78 79 None. 80 81 -Exceptions 82 83 1) If the input set argument does not qualify as a CSPICE set, 84 the error SPICE(NOTASET) will be signaled. CSPICE sets have 85 their data elements sorted in increasing order and contain 86 no duplicate data elements. 87 88 2) If the input set does not have double precision data type, 89 the error SPICE(TYPEMISMATCH will be signaled. 90 91 -Files 92 93 None. 94 95 -Particulars 96 97 This routine uses a binary search to check for the presence in the set 98 of the specified item. 99 100 -Examples 101 102 Let set contain the elements 103 104 { -1.0, 0.0, 1.0, 3.0, 5.0 } 105 106 The the following expressions have the value SPICETRUE 107 108 elemd_c ( -1.0, &set ) 109 elemd_c ( 0.0, &set ) 110 elemd_c ( 3.0, &set ) 111 112 and the following expressions have the value SPICEFALSE 113 114 elemd_c ( -2.0, &set ) 115 elemd_c ( 2.0, &set ) 116 elemd_c ( 6.0, &set ) 117 118 -Restrictions 119 120 None. 121 122 -Literature_References 123 124 None. 125 126 -Author_and_Institution 127 128 N.J. Bachman (JPL) 129 C.A. Curzon (JPL) 130 H.A. Neilan (JPL) 131 W.L. Taber (JPL) 132 I.M. Underwood (JPL) 133 134 -Version 135 136 -CSPICE Version 1.0.0, 07-AUG-2002 (NJB) (CAC) (HAN) (WLT) (IMU) 137 138 -Index_Entries 139 140 element of a d.p. set 141 142 -& 143 */ 144 { 145 146 /* 147 Use discovery check-in. 148 149 Make sure we're working with a double precision cell. 150 */ 151 CELLTYPECHK_VAL ( CHK_DISCOVER, "elemd_c", SPICE_DP, set, SPICEFALSE ); 152 153 /* 154 Make sure the input cell is a set. 155 */ 156 CELLISSETCHK_VAL ( CHK_DISCOVER, "elemd_c", set, SPICEFALSE ); 157 158 /* 159 Initialize the set if necessary. 160 */ 161 CELLINIT ( set ); 162 163 /* 164 The routine bsrchd_c returns the index of the item in the set, 165 or -1 if the item is not present. 166 */ 167 return ( bsrchd_c ( item, set->card, set->data ) != -1 ); 168 } 169 170 171