Changeset 901


Ignore:
Timestamp:
Sep 4, 2011, 2:28:59 PM (8 years ago)
Author:
sam
Message:

core: fix an accuracy error in the cos() part of lol_sincos().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/trig.cpp

    r900 r901  
    388388    if (lol_fabs(absx) > QUARTER)
    389389    {
    390         sign = (x * absx >= 0.0) ? sign : -sign;
     390        cos_sign = sin_sign;
     391        sin_sign = (x * absx >= 0.0) ? sin_sign : -sin_sign;
    391392
    392393        double x1 = HALF - lol_fabs(absx);
     
    397398        double subs2 = (CC[4] * x4 + CC[2]) * x4 + CC[0];
    398399        double taylors = subs2 * x2 + subs1;
    399         *sinx = taylors * sign;
    400 
    401         double subc1 = (SC[3] * x4 + SC[1]) * x4 + ONE;
     400        *sinx = taylors * sin_sign;
     401
     402        double subc1 = ((SC[5] * x4 + SC[3]) * x4 + SC[1]) * x4 + ONE;
    402403        double subc2 = (SC[4] * x4 + SC[2]) * x4 + SC[0];
    403404        double taylorc = subc2 * x2 + subc1;
    404         *cosx = x1 * taylorc * sign * PI;
     405        *cosx = x1 * taylorc * cos_sign * PI;
    405406
    406407        return;
     
    408409#endif
    409410
     411#if !defined __CELLOS_LV2__
    410412    sin_sign *= (x >= 0.0) ? PI : NEG_PI;
     413#endif
    411414
    412415    double x2 = absx * absx;
    413416    double x4 = x2 * x2;
    414417#if defined LOL_FEATURE_VERY_CHEAP_BRANCHES
    415     double subs1 = ((CC[5] * x4 + SC[3]) * x4 + SC[1]) * x4 + ONE;
     418    double subs1 = ((SC[5] * x4 + SC[3]) * x4 + SC[1]) * x4 + ONE;
    416419    double subs2 = (SC[4] * x4 + SC[2]) * x4 + SC[0];
    417420    double subc1 = ((CC[5] * x4 + CC[3]) * x4 + CC[1]) * x4 + ONE;
Note: See TracChangeset for help on using the changeset viewer.