Changeset 54 for trunk/orca/math.c
- Timestamp:
- 02/17/06 15:30:01 (3 years ago)
- Files:
-
- 1 modified
-
trunk/orca/math.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/orca/math.c
r42 r54 42 42 double n; \ 43 43 if( a1->type == OT_DECIMAL ) { \ 44 n = a1->num.decimal; \44 n = orDecimal(a1); \ 45 45 } else { \ 46 n = (double) a1->integer; \46 n = (double) orInt(a1); \ 47 47 orSetTF( a1, OT_DECIMAL ); \ 48 48 } \ 49 49 if( orRefineSet(REF_RADIANS) ) \ 50 a1->num.decimal= func( n ); \50 orDecimal(a1) = func( n ); \ 51 51 else \ 52 a1->num.decimal= func( DEG_TO_RAD * n );52 orDecimal(a1) = func( DEG_TO_RAD * n ); 53 53 54 54 … … 94 94 if( a1->type == OT_DECIMAL ) 95 95 { 96 n = a1->num.decimal;96 n = orDecimal(a1); 97 97 } 98 98 else 99 99 { 100 n = (double) a1->integer;100 n = (double) orInt(a1); 101 101 orSetTF( a1, OT_DECIMAL ); 102 102 } 103 a1->num.decimal= mathSqrt( n );103 orDecimal(a1) = mathSqrt( n ); 104 104 } 105 105 … … 114 114 { 115 115 unsigned long seed; 116 if( a1->integer)117 seed = a1->integer;116 if( orInt(a1) ) 117 seed = orInt(a1); 118 118 else 119 119 seed = randomSeed(); … … 122 122 else 123 123 { 124 if( orIsSeries( a1->type) )124 if( orIsSeries( orType(a1) ) ) 125 125 { 126 126 if( orRefineSet(REF_RAND_ONLY) ) … … 144 144 } 145 145 } 146 else if( a1->type == OT_DECIMAL)147 { 148 a1->num.decimal*= genrand_real2();146 else if( orIs(a1, OT_DECIMAL) ) 147 { 148 orDecimal(a1) *= genrand_real2(); 149 149 return; 150 150 } 151 else if( a1->type == OT_INTEGER)151 else if( orIs(a1, OT_INTEGER) ) 152 152 { 153 153 unsigned long rn = genrand_int32(); 154 a1->integer = (rn % a1->integer) + 1;154 orInt(a1) = (rn % orInt(a1)) + 1; 155 155 return; 156 156 } 157 else if( a1->type == OT_LOGIC)158 { 159 a1->integer= genrand_int32() & 1;157 else if( orIs(a1, OT_LOGIC) ) 158 { 159 orInt(a1) = genrand_int32() & 1; 160 160 return; 161 161 } … … 179 179 { 180 180 int sum; 181 int n = b->integer;181 int n = orInt(b); 182 182 if( n ) 183 183 { 184 sum = a->integer;184 sum = orInt(a); 185 185 while( --n ) 186 sum *= a->integer;186 sum *= orInt(a); 187 187 } 188 188 else … … 195 195 else if( b->type == OT_DECIMAL ) 196 196 { 197 x = (double) a->integer;198 y = b->num.decimal;197 x = (double) orInt(a); 198 y = orDecimal(b); 199 199 goto fp; 200 200 } … … 203 203 else if( a->type == OT_DECIMAL ) 204 204 { 205 x = a->num.decimal;205 x = orDecimal(a); 206 206 if( b->type == OT_INTEGER ) 207 207 { 208 y = (double) b->integer;208 y = (double) orInt(b); 209 209 goto fp; 210 210 } 211 211 else if( b->type == OT_DECIMAL ) 212 212 { 213 y = b->num.decimal;213 y = orDecimal(b); 214 214 goto fp; 215 215 } … … 232 232 if( b->type == OT_INTEGER ) 233 233 { 234 orResult( OT_INTEGER, a->integer % b->integer);234 orResult( OT_INTEGER, orInt(a) % orInt(b) ); 235 235 return; 236 236 } 237 237 else if( b->type == OT_DECIMAL ) 238 238 { 239 x = (double) a->integer;240 y = b->num.decimal;239 x = (double) orInt(a); 240 y = orDecimal(b); 241 241 goto fp; 242 242 } … … 245 245 else if( a->type == OT_DECIMAL ) 246 246 { 247 x = a->num.decimal;247 x = orDecimal(a); 248 248 if( b->type == OT_INTEGER ) 249 249 { 250 y = (double) b->integer;250 y = (double) orInt(b); 251 251 goto fp; 252 252 } 253 253 else if( b->type == OT_DECIMAL ) 254 254 { 255 y = b->num.decimal;255 y = orDecimal(b); 256 256 goto fp; 257 257 } … … 271 271 { 272 272 case OT_LOGIC: 273 a1->integer^= 1;273 orInt(a1) ^= 1; 274 274 break; 275 275 276 276 case OT_INTEGER: 277 a1->integer = ~a1->integer;277 orInt(a1) = ~orInt(a1); 278 278 break; 279 279 … … 300 300 { 301 301 case OT_INTEGER: 302 if( a1->integer< 0 )303 a1->integer = -a1->integer;302 if( orInt(a1) < 0 ) 303 orInt(a1) = -orInt(a1); 304 304 break; 305 305 306 306 case OT_DECIMAL: 307 if( a1->num.decimal< 0.0 )308 a1->num.decimal = -a1->num.decimal;307 if( orDecimal(a1) < 0.0 ) 308 orDecimal(a1) = -orDecimal(a1); 309 309 break; 310 310 … … 328 328 { 329 329 case OT_INTEGER: 330 a1->integer = -a1->integer;330 orInt(a1) = -orInt(a1); 331 331 break; 332 332 333 333 case OT_DECIMAL: 334 a1->num.decimal = -a1->num.decimal;334 orDecimal(a1) = -orDecimal(a1); 335 335 break; 336 336 … … 373 373 val = orIntern( &ctx, "pi", 2, 0 ); 374 374 orSetTF( val, OT_DECIMAL ); 375 val->num.decimal= PI;375 orDecimal(val) = PI; 376 376 377 377 init_genrand( randomSeed() );
