Changeset 5edfe12 in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Nov 24, 2015 4:13:15 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
7f7f99f
Parents:
92da231
Message:

support long double kernels for precision limited models

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    rcd3dba0 r5edfe12  
    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 
     208F128 = np.dtype('float128') 
    208209F64 = np.dtype('float64') 
    209210F32 = np.dtype('float32') 
     
    322323    source = re.sub(r'[^a-zA-Z_](\d*[.]\d+|\d+[.]\d*)([eE][+-]?\d+)?', 
    323324                    r'\g<0>f', source) 
     325    return source 
     326 
     327def use_long_double(source): 
     328    """ 
     329    Convert code from double precision to long double precision. 
     330    """ 
     331    # Convert double keyword to float.  Accept an 'n' parameter for vector 
     332    # values, where n is 2, 4, 8 or 16. Assume complex numbers are represented 
     333    # as cdouble which is typedef'd to double2. 
     334    source = re.sub(r'(^|[^a-zA-Z0-9_]c?)double(([248]|16)?($|[^a-zA-Z0-9_]))', 
     335                    r'\1long double\2', source) 
     336    # Convert floating point constants to single by adding 'f' to the end. 
     337    # OS/X driver complains if you don't do this. 
     338    source = re.sub(r'[^a-zA-Z_](\d*[.]\d+|\d+[.]\d*)([eE][+-]?\d+)?', 
     339                    r'\g<0>L', source) 
    324340    return source 
    325341 
Note: See TracChangeset for help on using the changeset viewer.