Changeset 4f2478e in sasmodels for sasmodels/models/lib
- Timestamp:
- Jan 28, 2016 1:19:03 PM (8 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/lib/sph_j1c.c
r9c461c7 r4f2478e 1 1 /** 2 * Spherical Bessel function j1(x)/x2 * Spherical Bessel function 3*j1(x)/x 3 3 * 4 4 * Used for low q to avoid cancellation error. … … 8 8 * requires the first 3 terms. Double precision requires the 4th term. 9 9 * 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; 10 15 */ 11 16 … … 18 23 SINCOS(q, sin_q, cos_q); 19 24 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.)) 22 27 : 3.0*(sin_q/q - cos_q)/q2; 23 28 24 29 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 */ 25 45 }
Note: See TracChangeset
for help on using the changeset viewer.