Changes in explore/precision.py [fba9ca0:cd28947] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
explore/precision.py
rfba9ca0 rcd28947 207 207 return model_info 208 208 209 # Hack to allow second parameter A in two parameter functions 209 # Hack to allow second parameter A in the gammainc and gammaincc functions. 210 # Create a 2-D variant of the precision test if we need to handle other two 211 # parameter functions. 210 212 A = 1 211 213 def parse_extra_pars(): 214 """ 215 Parse the command line looking for the second parameter "A=..." for the 216 gammainc/gammaincc functions. 217 """ 212 218 global A 213 219 … … 333 339 ) 334 340 add_function( 341 # Note: "a" is given as A=... on the command line via parse_extra_pars 335 342 name="gammainc(x)", 336 343 mp_function=lambda x, a=A: mp.gammainc(a, a=0, b=x)/mp.gamma(a), … … 339 346 ) 340 347 add_function( 348 # Note: "a" is given as A=... on the command line via parse_extra_pars 341 349 name="gammaincc(x)", 342 350 mp_function=lambda x, a=A: mp.gammainc(a, a=x, b=mp.inf)/mp.gamma(a), … … 403 411 ) 404 412 add_function( 405 name=" debye",413 name="gauss_coil", 406 414 mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 407 415 np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 408 416 ocl_function=make_ocl(""" 409 417 const double qsq = q*q; 410 if (qsq < 1.0) { // Pade approximation 418 // For double: use O(5) Pade with 0.5 cutoff (10 mad + 1 divide) 419 // For single: use O(7) Taylor with 0.8 cutoff (7 mad) 420 if (qsq < 0.0) { 411 421 const double x = qsq; 412 422 if (0) { // 0.36 single … … 418 428 const double B1=3./8., B2=3./56., B3=1./336.; 419 429 return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); 420 } else if ( 1) { // 1.0 for single, 0.25 for double430 } else if (0) { // 1.0 for single, 0.25 for double 421 431 // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 422 432 const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; … … 431 441 /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 432 442 } 433 } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double443 } else if (qsq < 0.8) { 434 444 const double x = qsq; 435 445 const double C0 = +1.;
Note: See TracChangeset
for help on using the changeset viewer.