Changes in explore/precision.py [cd28947:fba9ca0] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/precision.py

    rcd28947 rfba9ca0  
    207207    return model_info 
    208208 
    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. 
     209# Hack to allow second parameter A in two parameter functions 
    212210A = 1 
    213211def parse_extra_pars(): 
    214     """ 
    215     Parse the command line looking for the second parameter "A=..." for the 
    216     gammainc/gammaincc functions. 
    217     """ 
    218212    global A 
    219213 
     
    339333) 
    340334add_function( 
    341     # Note: "a" is given as A=... on the command line via parse_extra_pars 
    342335    name="gammainc(x)", 
    343336    mp_function=lambda x, a=A: mp.gammainc(a, a=0, b=x)/mp.gamma(a), 
     
    346339) 
    347340add_function( 
    348     # Note: "a" is given as A=... on the command line via parse_extra_pars 
    349341    name="gammaincc(x)", 
    350342    mp_function=lambda x, a=A: mp.gammainc(a, a=x, b=mp.inf)/mp.gamma(a), 
     
    411403) 
    412404add_function( 
    413     name="gauss_coil", 
     405    name="debye", 
    414406    mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 
    415407    np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 
    416408    ocl_function=make_ocl(""" 
    417409    const double qsq = q*q; 
    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) { 
     410    if (qsq < 1.0) { // Pade approximation 
    421411        const double x = qsq; 
    422412        if (0) { // 0.36 single 
     
    428418            const double B1=3./8., B2=3./56., B3=1./336.; 
    429419            return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); 
    430         } else if (0) { // 1.0 for single, 0.25 for double 
     420        } else if (1) { // 1.0 for single, 0.25 for double 
    431421            // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
    432422            const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; 
     
    441431                  /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 
    442432        } 
    443     } else if (qsq < 0.8) { 
     433    } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double 
    444434        const double x = qsq; 
    445435        const double C0 = +1.; 
Note: See TracChangeset for help on using the changeset viewer.