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


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/precision.py

    rfba9ca0 rcd28947  
    207207    return model_info 
    208208 
    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. 
    210212A = 1 
    211213def parse_extra_pars(): 
     214    """ 
     215    Parse the command line looking for the second parameter "A=..." for the 
     216    gammainc/gammaincc functions. 
     217    """ 
    212218    global A 
    213219 
     
    333339) 
    334340add_function( 
     341    # Note: "a" is given as A=... on the command line via parse_extra_pars 
    335342    name="gammainc(x)", 
    336343    mp_function=lambda x, a=A: mp.gammainc(a, a=0, b=x)/mp.gamma(a), 
     
    339346) 
    340347add_function( 
     348    # Note: "a" is given as A=... on the command line via parse_extra_pars 
    341349    name="gammaincc(x)", 
    342350    mp_function=lambda x, a=A: mp.gammainc(a, a=x, b=mp.inf)/mp.gamma(a), 
     
    403411) 
    404412add_function( 
    405     name="debye", 
     413    name="gauss_coil", 
    406414    mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 
    407415    np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 
    408416    ocl_function=make_ocl(""" 
    409417    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) { 
    411421        const double x = qsq; 
    412422        if (0) { // 0.36 single 
     
    418428            const double B1=3./8., B2=3./56., B3=1./336.; 
    419429            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 double 
     430        } else if (0) { // 1.0 for single, 0.25 for double 
    421431            // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
    422432            const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; 
     
    431441                  /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 
    432442        } 
    433     } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double 
     443    } else if (qsq < 0.8) { 
    434444        const double x = qsq; 
    435445        const double C0 = +1.; 
Note: See TracChangeset for help on using the changeset viewer.