Changeset f719764 in sasmodels


Ignore:
Timestamp:
Oct 17, 2016 1:42:01 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
9aa4881
Parents:
2126131
Message:

fix error introduced when converting to SINCOS macro and Horner's method for polyval

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/lib/Si.c

    ra5b6997 rf719764  
    33double Si(double x) 
    44{ 
    5     if (x >= M_PI*6.2/4.0){ 
    6         const double z = 1./(x*x); 
     5    if (x >= M_PI*6.2/4.0) { 
     6        const double xxinv = 1./(x*x); 
    77        // Explicitly writing factorial values triples the speed of the calculation 
    8         const double out_cos = (((-720.*z + 24.)*z - 2.)*z + 1.)/x; 
    9         const double out_sin = (((-5040.*z + 120.)*z - 6.)*z + 1)*z; 
     8        const double out_cos = (((-720.*xxinv + 24.)*xxinv - 2.)*xxinv + 1.)/x; 
     9        const double out_sin = (((-5040.*xxinv + 120.)*xxinv - 6.)*xxinv + 1)*xxinv; 
    1010 
    11         double cos_x, sin_x; 
    12         SINCOS(x, cos_x, sin_x); 
     11        double sin_x, cos_x; 
     12        SINCOS(x, sin_x, cos_x); 
    1313        return M_PI_2 - cos_x*out_cos - sin_x*out_sin; 
    1414    } else { 
    15         const double z = x*x; 
     15        const double xx = x*x; 
    1616        // Explicitly writing factorial values triples the speed of the calculation 
    17         return (((((-1./439084800.*z 
    18             + 1./3265920.)*z 
    19             - 1./35280.)*z 
    20             + 1./600.)*z 
    21             - 1./18.)*z 
     17        return (((((-1./439084800.*xx 
     18            + 1./3265920.)*xx 
     19            - 1./35280.)*xx 
     20            + 1./600.)*xx 
     21            - 1./18.)*xx 
    2222            + 1.)*x; 
    2323    } 
Note: See TracChangeset for help on using the changeset viewer.