Changes in sasmodels/generate.py [cd3dba0:e1ace4d] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    rcd3dba0 re1ace4d  
    197197# TODO: identify model files which have changed since loading and reload them. 
    198198 
    199 __all__ = ["make", "doc", "sources", "use_single"] 
     199__all__ = ["make", "doc", "sources", "use_single", "use_long_double"] 
    200200 
    201201import sys 
     
    206206C_KERNEL_TEMPLATE_PATH = joinpath(dirname(__file__), 'kernel_template.c') 
    207207 
     208F32 = np.dtype('float32') 
    208209F64 = np.dtype('float64') 
    209 F32 = np.dtype('float32') 
     210try:  # CRUFT: older numpy does not support float128 
     211    F128 = np.dtype('float128') 
     212except TypeError: 
     213    F128 = None 
     214 
    210215 
    211216# Scale and background, which are parameters common to every form factor 
     
    322327    source = re.sub(r'[^a-zA-Z_](\d*[.]\d+|\d+[.]\d*)([eE][+-]?\d+)?', 
    323328                    r'\g<0>f', source) 
     329    return source 
     330 
     331def use_long_double(source): 
     332    """ 
     333    Convert code from double precision to long double precision. 
     334    """ 
     335    # Convert double keyword to float.  Accept an 'n' parameter for vector 
     336    # values, where n is 2, 4, 8 or 16. Assume complex numbers are represented 
     337    # as cdouble which is typedef'd to double2. 
     338    source = re.sub(r'(^|[^a-zA-Z0-9_]c?)double(([248]|16)?($|[^a-zA-Z0-9_]))', 
     339                    r'\1long double\2', source) 
     340    # Convert floating point constants to single by adding 'f' to the end. 
     341    # OS/X driver complains if you don't do this. 
     342    source = re.sub(r'[^a-zA-Z_](\d*[.]\d+|\d+[.]\d*)([eE][+-]?\d+)?', 
     343                    r'\g<0>L', source) 
    324344    return source 
    325345 
Note: See TracChangeset for help on using the changeset viewer.