source: sasmodels/sasmodels/models/lib/sas_Si.c @ 473a9f1

core_shell_microgelscostrafo411magnetic_modelticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 473a9f1 was 473a9f1, checked in by wojciech, 7 years ago

Changed function and files names in lib to comply with new standards

  • Property mode set to 100644
File size: 853 bytes
RevLine 
[0420af7]1// integral of sin(x)/x Taylor series approximated to w/i 0.1%
[473a9f1]2double sas_Si(double x);
3double sas_Si(double x)
[cf404cb]4{
[f719764]5    if (x >= M_PI*6.2/4.0) {
6        const double xxinv = 1./(x*x);
[e7678b2]7        // Explicitly writing factorial values triples the speed of the calculation
[f719764]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;
[cf404cb]10
[f719764]11        double sin_x, cos_x;
12        SINCOS(x, sin_x, cos_x);
[a5b6997]13        return M_PI_2 - cos_x*out_cos - sin_x*out_sin;
14    } else {
[f719764]15        const double xx = x*x;
[a5b6997]16        // Explicitly writing factorial values triples the speed of the calculation
[f719764]17        return (((((-1./439084800.*xx
18            + 1./3265920.)*xx
19            - 1./35280.)*xx
20            + 1./600.)*xx
21            - 1./18.)*xx
[a5b6997]22            + 1.)*x;
[e7678b2]23    }
[f719764]24}
Note: See TracBrowser for help on using the repository browser.