Changeset 898


Ignore:
Timestamp:
Sep 4, 2011, 12:06:00 AM (8 years ago)
Author:
sam
Message:

core: slightly reorganise Taylor series in sin() and cos().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/trig.cpp

    r897 r898  
    191191        double x2 = absx * absx;
    192192        double x4 = x2 * x2;
    193         double sub1 = SC[3] * x4 + SC[1];
     193        double sub1 = (SC[3] * x4 + SC[1]) * x4 + ONE;
    194194        double sub2 = (SC[4] * x4 + SC[2]) * x4 + SC[0];
    195         double taylor = (sub1 * x2 + sub2) * x2 + ONE;
     195        double taylor = sub2 * x2 + sub1;
    196196        return x * taylor;
    197197    }
     
    229229        double x2 = x1 * x1;
    230230        double x4 = x2 * x2;
    231         double sub1 = (CC[5] * x4 + CC[3]) * x4 + CC[1];
     231        double sub1 = ((CC[5] * x4 + CC[3]) * x4 + CC[1]) * x4 + ONE;
    232232        double sub2 = (CC[4] * x4 + CC[2]) * x4 + CC[0];
    233         double taylor = (sub1 * x2 + sub2) * x2 + ONE;
     233        double taylor = sub2 * x2 + sub1;
    234234
    235235        return taylor * sign;
     
    242242    double x4 = x2 * x2;
    243243#if defined LOL_FEATURE_VERY_CHEAP_BRANCHES
    244     double sub1 = SC[3] * x4 + SC[1];
     244    double sub1 = (SC[3] * x4 + SC[1]) * x4 + ONE;
    245245    double sub2 = (SC[4] * x4 + SC[2]) * x4 + SC[0];
    246246#else
    247     double sub1 = ((SC[7] * x4 + SC[5]) * x4 + SC[3]) * x4 + SC[1];
     247    double sub1 = (((SC[7] * x4 + SC[5]) * x4 + SC[3]) * x4 + SC[1]) * x4 + ONE;
    248248    double sub2 = ((SC[6] * x4 + SC[4]) * x4 + SC[2]) * x4 + SC[0];
    249249#endif
    250     double taylor = (sub1 * x2 + sub2) * x2 + ONE;
     250    double taylor = sub2 * x2 + sub1;
    251251
    252252    return absx * taylor * sign;
     
    303303    double x4 = x2 * x2;
    304304#if defined LOL_FEATURE_VERY_CHEAP_BRANCHES
    305     double sub1 = (CC[5] * x4 + CC[3]) * x4 + CC[1];
     305    double sub1 = ((CC[5] * x4 + CC[3]) * x4 + CC[1]) * x4 + ONE;
    306306    double sub2 = (CC[4] * x4 + CC[2]) * x4 + CC[0];
    307307#else
    308     double sub1 = ((CC[7] * x4 + CC[5]) * x4 + CC[3]) * x4 + CC[1];
     308    double sub1 = (((CC[7] * x4 + CC[5]) * x4 + CC[3]) * x4 + CC[1]) * x4 + ONE;
    309309    double sub2 = ((CC[6] * x4 + CC[4]) * x4 + CC[2]) * x4 + CC[0];
    310310#endif
    311     double taylor = (sub1 * x2 + sub2) * x2 + ONE;
     311    double taylor = sub2 * x2 + sub1;
    312312
    313313    return taylor * sign;
Note: See TracChangeset for help on using the changeset viewer.