Changeset 54 for trunk/orca/math.c

Show
Ignore:
Timestamp:
02/17/06 15:30:01 (3 years ago)
Author:
krobillard
Message:

Now using orDecimal() & orInt() where appropriate.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/orca/math.c

    r42 r54  
    4242    double n; \ 
    4343    if( a1->type == OT_DECIMAL ) { \ 
    44         n = a1->num.decimal; \ 
     44        n = orDecimal(a1); \ 
    4545    } else { \ 
    46         n = (double) a1->integer; \ 
     46        n = (double) orInt(a1); \ 
    4747        orSetTF( a1, OT_DECIMAL ); \ 
    4848    } \ 
    4949    if( orRefineSet(REF_RADIANS) ) \ 
    50         a1->num.decimal = func( n ); \ 
     50        orDecimal(a1) = func( n ); \ 
    5151    else \ 
    52         a1->num.decimal = func( DEG_TO_RAD * n ); 
     52        orDecimal(a1) = func( DEG_TO_RAD * n ); 
    5353 
    5454 
     
    9494    if( a1->type == OT_DECIMAL ) 
    9595    { 
    96         n = a1->num.decimal; 
     96        n = orDecimal(a1); 
    9797    } 
    9898    else 
    9999    { 
    100         n = (double) a1->integer; 
     100        n = (double) orInt(a1); 
    101101        orSetTF( a1, OT_DECIMAL ); 
    102102    } 
    103     a1->num.decimal = mathSqrt( n ); 
     103    orDecimal(a1) = mathSqrt( n ); 
    104104} 
    105105 
     
    114114    { 
    115115        unsigned long seed; 
    116         if( a1->integer ) 
    117             seed = a1->integer; 
     116        if( orInt(a1) ) 
     117            seed = orInt(a1); 
    118118        else 
    119119            seed = randomSeed(); 
     
    122122    else 
    123123    { 
    124         if( orIsSeries(a1->type) ) 
     124        if( orIsSeries( orType(a1) ) ) 
    125125        { 
    126126            if( orRefineSet(REF_RAND_ONLY) ) 
     
    144144            } 
    145145        } 
    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(); 
    149149            return; 
    150150        } 
    151         else if( a1->type == OT_INTEGER ) 
     151        else if( orIs(a1, OT_INTEGER) ) 
    152152        { 
    153153            unsigned long rn = genrand_int32(); 
    154             a1->integer = (rn % a1->integer) + 1; 
     154            orInt(a1) = (rn % orInt(a1)) + 1; 
    155155            return; 
    156156        } 
    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; 
    160160            return; 
    161161        } 
     
    179179        { 
    180180            int sum; 
    181             int n = b->integer; 
     181            int n = orInt(b); 
    182182            if( n ) 
    183183            { 
    184                 sum = a->integer; 
     184                sum = orInt(a); 
    185185                while( --n ) 
    186                     sum *= a->integer; 
     186                    sum *= orInt(a); 
    187187            } 
    188188            else 
     
    195195        else if( b->type == OT_DECIMAL ) 
    196196        { 
    197             x = (double) a->integer; 
    198             y = b->num.decimal; 
     197            x = (double) orInt(a); 
     198            y = orDecimal(b); 
    199199            goto fp; 
    200200        } 
     
    203203    else if( a->type == OT_DECIMAL ) 
    204204    { 
    205         x = a->num.decimal; 
     205        x = orDecimal(a); 
    206206        if( b->type == OT_INTEGER ) 
    207207        { 
    208             y = (double) b->integer; 
     208            y = (double) orInt(b); 
    209209            goto fp; 
    210210        } 
    211211        else if( b->type == OT_DECIMAL ) 
    212212        { 
    213             y = b->num.decimal; 
     213            y = orDecimal(b); 
    214214            goto fp; 
    215215        } 
     
    232232        if( b->type == OT_INTEGER ) 
    233233        { 
    234             orResult( OT_INTEGER, a->integer % b->integer ); 
     234            orResult( OT_INTEGER, orInt(a) % orInt(b) ); 
    235235            return; 
    236236        } 
    237237        else if( b->type == OT_DECIMAL ) 
    238238        { 
    239             x = (double) a->integer; 
    240             y = b->num.decimal; 
     239            x = (double) orInt(a); 
     240            y = orDecimal(b); 
    241241            goto fp; 
    242242        } 
     
    245245    else if( a->type == OT_DECIMAL ) 
    246246    { 
    247         x = a->num.decimal; 
     247        x = orDecimal(a); 
    248248        if( b->type == OT_INTEGER ) 
    249249        { 
    250             y = (double) b->integer; 
     250            y = (double) orInt(b); 
    251251            goto fp; 
    252252        } 
    253253        else if( b->type == OT_DECIMAL ) 
    254254        { 
    255             y = b->num.decimal; 
     255            y = orDecimal(b); 
    256256            goto fp; 
    257257        } 
     
    271271    { 
    272272        case OT_LOGIC: 
    273             a1->integer ^= 1; 
     273            orInt(a1) ^= 1; 
    274274            break; 
    275275 
    276276        case OT_INTEGER: 
    277             a1->integer = ~a1->integer; 
     277            orInt(a1) = ~orInt(a1); 
    278278            break; 
    279279 
     
    300300    { 
    301301        case OT_INTEGER: 
    302             if( a1->integer < 0 ) 
    303                 a1->integer = -a1->integer; 
     302            if( orInt(a1) < 0 ) 
     303                orInt(a1) = -orInt(a1); 
    304304            break; 
    305305 
    306306        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); 
    309309            break; 
    310310 
     
    328328    { 
    329329        case OT_INTEGER: 
    330             a1->integer = -a1->integer; 
     330            orInt(a1) = -orInt(a1); 
    331331            break; 
    332332 
    333333        case OT_DECIMAL: 
    334             a1->num.decimal = -a1->num.decimal; 
     334            orDecimal(a1) = -orDecimal(a1); 
    335335            break; 
    336336 
     
    373373    val = orIntern( &ctx, "pi", 2, 0 ); 
    374374    orSetTF( val, OT_DECIMAL ); 
    375     val->num.decimal = PI; 
     375    orDecimal(val) = PI; 
    376376 
    377377    init_genrand( randomSeed() );