Changeset 0a9fcab in sasmodels
- Timestamp:
- Dec 4, 2017 8:13:55 AM (7 years ago)
- Children:
- 2db9fe4
- Parents:
- ef6a512
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/plugin.rst
r3048ec6 r0a9fcab 543 543 M_PI, M_PI_2, M_PI_4, M_SQRT1_2, M_E: 544 544 $\pi$, $\pi/2$, $\pi/4$, $1/\sqrt{2}$ and Euler's constant $e$ 545 exp, log, pow(x,y), expm1, sqrt:546 Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\ sqrt{x}$.547 The function expm1(x) is accurate across all $x$, including $x$548 very close to zero.545 exp, log, pow(x,y), expm1, log1p, sqrt, cbrt: 546 Power functions $e^x$, $\ln x$, $x^y$, $e^x - 1$, $\ln 1 + x$, 547 $\sqrt{x}$, $\sqrt[3]{x}$. The functions expm1(x) and log1p(x) 548 are accurate across all $x$, including $x$ very close to zero. 549 549 sin, cos, tan, asin, acos, atan: 550 550 Trigonometry functions and inverses, operating on radians. … … 557 557 atan(y/x) would return a value in quadrant I. Similarly for 558 558 quadrants II and IV when $x$ and $y$ have opposite sign. 559 f min(x,y), fmax(x,y), trunc, rint:559 fabs(x), fmin(x,y), fmax(x,y), trunc, rint: 560 560 Floating point functions. rint(x) returns the nearest integer. 561 561 NAN: 562 562 NaN, Not a Number, $0/0$. Use isnan(x) to test for NaN. Note that 563 563 you cannot use :code:`x == NAN` to test for NaN values since that 564 will always return false. NAN does not equal NAN! 564 will always return false. NAN does not equal NAN! The alternative, 565 :code:`x != x` may fail if the compiler optimizes the test away. 565 566 INFINITY: 566 567 $\infty, 1/0$. Use isinf(x) to test for infinity, or isfinite(x) … … 734 735 Similar arrays are available in :code:`gauss20.c` for 20-point 735 736 quadrature and in :code:`gauss150.c` for 150-point quadrature. 737 The macros :code:`GAUSS_N`, :code:`GAUSS_Z` and :code:`GAUSS_W` are 738 defined so that you can change the order of the integration by 739 selecting an different source without touching the C code. 736 740 737 741 :code:`source = ["lib/gauss76.c", ...]` -
sasmodels/autoc.py
ref6a512 r0a9fcab 67 67 while translate: 68 68 function_name, function = translate.pop(0) 69 source = inspect.getsource(function)70 tree = ast.parse(source)71 69 filename = function.__code__.co_filename 72 70 offset = function.__code__.co_firstlineno 73 71 refs = function.__code__.co_names 74 snippet = codegen.to_source(tree) #, filename, offset)75 code[function_name] = snippet76 72 depends[function_name] = set(refs) 73 source = inspect.getsource(function) 77 74 for name in refs: 78 75 if name in tagged or name in DEFINES: … … 99 96 elif isinstance(obj, special.Gauss): 100 97 libs.append('lib/gauss%d.c'%obj.n) 98 source = (source.replace(name+'.n', 'GAUSS_N') 99 .replace(name+'.z', 'GAUSS_Z') 100 .replace(name+'.w', 'GAUSS_W')) 101 101 else: 102 102 raise TypeError("Could not convert global %s of type %s" 103 103 % (name, str(type(obj)))) 104 104 105 tree = ast.parse(source) 106 snippet = codegen.to_source(tree) #, filename, offset) 107 code[function_name] = snippet 108 105 109 # remove duplicates from the dependecy list 106 unique_libs = []110 unique_libs = [] 107 111 for filename in libs: 108 112 if filename not in unique_libs: -
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.