Changeset 0a9fcab in sasmodels for sasmodels/special.py
- Timestamp:
- Dec 4, 2017 6:13:55 AM (6 years ago)
- Children:
- 2db9fe4
- Parents:
- ef6a512
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/special.py
ref6a512 r0a9fcab 3 3 ................. 4 4 5 The C code follows the C99 standard, with the usual math functions, 6 as defined in 7 `OpenCL <https://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/mathFunctions.html>`_. 8 This includes the following: 5 This following standard C99 math functions are available: 9 6 10 7 M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E: 11 8 $\pi$, $\pi/2$, $\pi/4$, $1/\sqrt{2}$ and Euler's constant $e$ 12 9 13 exp, log, pow(x,y), expm1, sqrt:14 Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\ sqrt{x}$.15 The function expm1(x) is accurate across all $x$, including $x$16 very close to zero.10 exp, log, pow(x,y), expm1, log1p, sqrt, cbrt: 11 Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\ln 1 + x$, 12 $\sqrt{x}$, $\sqrt[3]{x}$. The functions expm1(x) and log1p(x) 13 are accurate across all $x$, including $x$ very close to zero. 17 14 18 15 sin, cos, tan, asin, acos, atan: … … 29 26 quadrants II and IV when $x$ and $y$ have opposite sign. 30 27 31 f min(x,y), fmax(x,y), trunc, rint:28 fabs(x), fmin(x,y), fmax(x,y), trunc, rint: 32 29 Floating point functions. rint(x) returns the nearest integer. 33 30 … … 35 32 NaN, Not a Number, $0/0$. Use isnan(x) to test for NaN. Note that 36 33 you cannot use :code:`x == NAN` to test for NaN values since that 37 will always return false. NAN does not equal NAN! 34 will always return false. NAN does not equal NAN! The alternative, 35 :code:`x != x` may fail if the compiler optimizes the test away. 38 36 39 37 INFINITY: … … 89 87 for forcing a constant to stay double precision. 90 88 91 The following special functions and scattering calculations are defined in 92 `sasmodels/models/lib <https://github.com/SasView/sasmodels/tree/master/sasmodels/models/lib>`_. 89 The following special functions and scattering calculations are defined. 93 90 These functions have been tuned to be fast and numerically stable down 94 91 to $q=0$ even in single precision. In some cases they work around bugs … … 184 181 185 182 186 Gauss76Z[i], Gauss76Wt[i]:183 gauss76.n, gauss76.z[i], gauss76.w[i]: 187 184 Points $z_i$ and weights $w_i$ for 76-point Gaussian quadrature, respectively, 188 185 computing $\int_{-1}^1 f(z)\,dz \approx \sum_{i=1}^{76} w_i\,f(z_i)$. 189 190 Similar arrays are available in :code:`gauss20.c` for 20-point 191 quadrature and in :code:`gauss150.c` for 150-point quadrature. 192 186 When translating the model to C, include 'lib/gauss76.c' in the source 187 and use :code:`GAUSS_N`, :code:`GAUSS_Z`, and :code:`GAUSS_W`. 188 189 Similar arrays are available in :code:`gauss20` for 20-point quadrature 190 and :code:`gauss150.c` for 150-point quadrature. By using 191 :code:`import gauss76 as gauss` it is easy to change the number of 192 points in the integration. 193 193 """ 194 194 # pylint: disable=unused-import … … 200 200 201 201 # C99 standard math library functions 202 from numpy import exp, log, power as pow, expm1, sqrt202 from numpy import exp, log, power as pow, expm1, logp1, sqrt, cbrt 203 203 from numpy import sin, cos, tan, arcsin as asin, arccos as acos, arctan as atan 204 204 from numpy import sinh, cosh, tanh, arcsinh as asinh, arccosh as acosh, arctanh as atanh 205 205 from numpy import arctan2 as atan2 206 from numpy import f min, fmax, trunc, rint206 from numpy import fabs, fmin, fmax, trunc, rint 207 207 from numpy import pi, nan, inf 208 208 from scipy.special import gamma as sas_gamma
Note: See TracChangeset
for help on using the changeset viewer.