source: sasmodels/sasmodels/models/lib/Si.c @ 1557a1e

core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change on this file since 1557a1e was 0278e3f, checked in by Paul Kienzle <pkienzle@…>, 9 years ago

remove opencl compiler warnings; maybe fix build server breakage

  • Property mode set to 100644
File size: 765 bytes
Line 
1// integral of sin(x)/x Taylor series approximated to w/i 0.1%
2double Si(double x);
3double Si(double x)
4{
5    double out;
6
7    if (x >= M_PI*6.2/4.0){
8        double out_sin = 0.0;
9        double out_cos = 0.0;
10        out = M_PI/2.0;
11
12        // Explicitly writing factorial values triples the speed of the calculation
13        out_cos = 1./x - 2./pow(x,3) + 24./pow(x,5) - 720./pow(x,7);
14        out_sin = 1./pow(x,2) - 6./pow(x,4) + 120./pow(x,6) - 5040./pow(x,8);
15
16        out -= cos(x) * out_cos;
17        out -= sin(x) * out_sin;
18        return out;
19    }
20
21    // Explicitly writing factorial values triples the speed of the calculation
22    out = x - pow(x, 3)/18. + pow(x,5)/600. - pow(x,7)/35280. + pow(x,9)/3265920. - pow(x,11)/439084800.;
23
24    return out;
25}
Note: See TracBrowser for help on using the repository browser.