Changeset 4f2478e in sasmodels for sasmodels/models/lib


Ignore:
Timestamp:
Jan 28, 2016 1:19:03 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
a3e78c3
Parents:
bf6631a
Message:

simplify calculation for sph_j1c

File:
1 edited

Legend:

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

    r9c461c7 r4f2478e  
    11/** 
    2 * Spherical Bessel function j1(x)/x 
     2* Spherical Bessel function 3*j1(x)/x 
    33* 
    44* Used for low q to avoid cancellation error. 
     
    88* requires the first 3 terms.  Double precision requires the 4th term. 
    99* The fifth term is not needed, and is commented out. 
     10* Taylor expansion: 
     11*      1.0 + q2*(-3./30. + q2*(3./840.))+ q2*(-3./45360. + q2*(3./3991680.)))) 
     12* Expression returned from Herbie (herbie.uwpise.org/demo): 
     13*      const double t = ((1. + 3.*q2*q2/5600.) - q2/20.); 
     14*      return t*t; 
    1015*/ 
    1116 
     
    1823    SINCOS(q, sin_q, cos_q); 
    1924 
    20     const double bessel = (q < 1.e-1) ? 
    21         1.0 + q2*(-3./30. + q2*(3./840. + q2*(-3./45360.))) // + q2*(3./3991680.))) 
     25    const double bessel = (q < 0.384038453352533) 
     26        ? (1.0 + q2*(-3./30. + q2*(3./840.)) 
    2227        : 3.0*(sin_q/q - cos_q)/q2; 
    2328 
    2429    return bessel; 
     30 
     31 /* 
     32    // Code to test various expressions 
     33    if (sizeof(q2) > 4) { 
     34        return 3.0*(sin_q/q - cos_q)/q2; 
     35    } else if (q < 0.384038453352533) { 
     36        //const double t = ((1. + 3.*q2*q2/5600.) - q2/20.); return t*t; 
     37        return 1.0 + q2*q2*(3./840.) - q2*(3./30.); 
     38        //return 1.0 + q2*(-3./30. + q2*(3./840.)); 
     39        //return 1.0 + q2*(-3./30. + q2*(3./840. + q2*(-3./45360.))); 
     40        //return 1.0 + q2*(-3./30. + q2*(3./840. + q2*(-3./45360. + q2*(3./3991680.)))); 
     41    } else { 
     42        return 3.0*(sin_q/q - cos_q)/q2; 
     43    } 
     44*/ 
    2545} 
Note: See TracChangeset for help on using the changeset viewer.