Changes in explore/precision.py [2a7e20e:2a602c7] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/precision.py

    r2a7e20e r2a602c7  
    107107        elif xrange == "linear": 
    108108            lin_min, lin_max, lin_steps = 1, 1000, 2000 
    109             lin_min, lin_max, lin_steps = 0.001, 2, 2000 
    110109        elif xrange == "log": 
    111110            log_min, log_max, log_steps = -3, 5, 400 
     
    345344) 
    346345add_function( 
    347     name="(1/2-sin(x)/x+(1-cos(x))/x^2)/x", 
     346    name="(1/2+(1-cos(x))/x^2-sin(x)/x)/x", 
    348347    mp_function=lambda x: (0.5 - mp.sin(x)/x + (1-mp.cos(x))/(x*x))/x, 
    349348    np_function=lambda x: (0.5 - np.sin(x)/x + (1-np.cos(x))/(x*x))/x, 
     
    355354    np_function=lambda x: np.fmod(x, 2*np.pi), 
    356355    ocl_function=make_ocl("return fmod(q, 2*M_PI);", "sas_fmod"), 
    357 ) 
    358 add_function( 
    359     name="debye", 
    360     mp_function=lambda x: 2*(mp.exp(-x**2) + x**2 - 1)/x**4, 
    361     np_function=lambda x: 2*(np.expm1(-x**2) + x**2)/x**4, 
    362     ocl_function=make_ocl(""" 
    363     const double qsq = q*q; 
    364     if (qsq < 1.0) { // Pade approximation 
    365         const double x = qsq; 
    366         if (0) { // 0.36 single 
    367             // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 4}] 
    368             return (x*x/180. + 1.)/((1./30.*x + 1./3.)*x + 1); 
    369         } else if (0) { // 1.0 for single 
    370             // padeapproximant[2*exp[-x^2] + x^2-1)/x^4, {x, 0, 6}] 
    371             const double A1=1./24., A2=1./84, A3=-1./3360; 
    372             const double B1=3./8., B2=3./56., B3=1./336.; 
    373             return (((A3*x + A2)*x + A1)*x + 1.)/(((B3*x + B2)*x + B1)*x + 1.); 
    374         } else if (1) { // 1.0 for single, 0.25 for double 
    375             // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
    376             const double A1=1./15., A2=1./60, A3=0., A4=1./75600.; 
    377             const double B1=2./5., B2=1./15., B3=1./180., B4=1./5040.; 
    378             return ((((A4*x + A3)*x + A2)*x + A1)*x + 1.) 
    379                   /((((B4*x + B3)*x + B2)*x + B1)*x + 1.); 
    380         } else { // 1.0 for single, 0.5 for double 
    381             // PadeApproximant[2*Exp[-x^2] + x^2-1)/x^4, {x, 0, 8}] 
    382             const double A1=1./12., A2=2./99., A3=1./2640., A4=1./23760., A5=-1./1995840.; 
    383             const double B1=5./12., B2=5./66., B3=1./132., B4=1./2376., B5=1./95040.; 
    384             return (((((A5*x + A4)*x + A3)*x + A2)*x + A1)*x + 1.) 
    385                   /(((((B5*x + B4)*x + B3)*x + B2)*x + B1)*x + 1.); 
    386         } 
    387     } else if (qsq < 1.) { // Taylor series; 0.9 for single, 0.25 for double 
    388         const double x = qsq; 
    389         const double C0 = +1.; 
    390         const double C1 = -1./3.; 
    391         const double C2 = +1./12.; 
    392         const double C3 = -1./60.; 
    393         const double C4 = +1./360.; 
    394         const double C5 = -1./2520.; 
    395         const double C6 = +1./20160.; 
    396         const double C7 = -1./181440.; 
    397         //return ((((C5*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
    398         //return (((((C6*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
    399         return ((((((C7*x + C6)*x + C5)*x + C4)*x + C3)*x + C2)*x + C1)*x + C0; 
    400     } else { 
    401         return 2.*(expm1(-qsq) + qsq)/(qsq*qsq); 
    402     } 
    403     """, "sas_debye"), 
    404356) 
    405357 
     
    609561    names = ", ".join(sorted(ALL_FUNCTIONS)) 
    610562    print("""\ 
    611 usage: precision.py [-f/a/r] [-x<range>] "name" ... 
     563usage: precision.py [-f/a/r] [-x<range>] name... 
    612564where 
    613565    -f indicates that the function value should be plotted, 
     
    620572      zoom indicates linear stepping in [1000, 1010] 
    621573      neg indicates linear stepping in [-100.1, 100.1] 
    622 and name is "all" or one of: 
     574and name is "all [first]" or one of: 
    623575    """+names) 
    624576    sys.exit(1) 
Note: See TracChangeset for help on using the changeset viewer.