core_shell_microgelscostrafo411magnetic_modelrelease_v0.94release_v0.95ticket-1257-vesicle-productticket_1156ticket_1265_superballticket_822_more_unit_tests
Last change
on this file since 9c461c7 was
9c461c7,
checked in by piotr, 8 years ago
|
- Code review from PK: renamed J1c to sph_j1c
- Fixed mass_fractal
|
-
Property mode set to
100644
|
File size:
753 bytes
|
Rev | Line | |
---|
[9c461c7] | 1 | /** |
---|
| 2 | * Spherical Bessel function j1(x)/x |
---|
| 3 | * |
---|
| 4 | * Used for low q to avoid cancellation error. |
---|
| 5 | * Note that the values differ from sasview ~ 5e-12 rather than 5e-14, but |
---|
| 6 | * in this case it is likely cancellation errors in the original expression |
---|
| 7 | * using double precision that are the source. Single precision only |
---|
| 8 | * requires the first 3 terms. Double precision requires the 4th term. |
---|
| 9 | * The fifth term is not needed, and is commented out. |
---|
| 10 | */ |
---|
| 11 | |
---|
| 12 | double sph_j1c(double q); |
---|
| 13 | double sph_j1c(double q) |
---|
| 14 | { |
---|
| 15 | const double q2 = q*q; |
---|
| 16 | double sin_q, cos_q; |
---|
| 17 | |
---|
| 18 | SINCOS(q, sin_q, cos_q); |
---|
| 19 | |
---|
| 20 | const double bessel = (q < 1.e-1) ? |
---|
| 21 | 1.0 + q2*(-3./30. + q2*(3./840. + q2*(-3./45360.))) // + q2*(3./3991680.))) |
---|
| 22 | : 3.0*(sin_q/q - cos_q)/q2; |
---|
| 23 | |
---|
| 24 | return bessel; |
---|
| 25 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.