Changeset c437dbb in sasmodels for sasmodels/generate.py


Ignore:
Timestamp:
Mar 1, 2016 1:40:08 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:
ce0b154
Parents:
cf85329
Message:

Improve accuracy of sph_j1c to 7 digits single, 14 digits double

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/generate.py

    rfa8011eb rc437dbb  
    193193and adds the parameter table to the top.  The function :func:`model_sources` 
    194194returns a list of files required by the model. 
     195 
     196Code follows the C99 standard with the following extensions and conditions:: 
     197 
     198    M_PI_180 = pi/180 
     199    M_4PI_3 = 4pi/3 
     200    square(x) = x*x 
     201    cube(x) = x*x*x 
     202    sinc(x) = sin(x)/x, with sin(0)/0 -> 1 
     203    all double precision constants must include the decimal point 
     204    all double declarations may be converted to half, float, or long double 
     205    FLOAT_SIZE is the number of bytes in the converted variables 
    195206""" 
    196207from __future__ import print_function 
     
    344355    """ 
    345356    if dtype == F16: 
     357        fbytes = 2 
    346358        source = _F16_PRAGMA + _convert_type(source, "half", "f") 
    347359    elif dtype == F32: 
     360        fbytes = 4 
    348361        source = _convert_type(source, "float", "f") 
    349362    elif dtype == F64: 
     363        fbytes = 8 
    350364        source = _F64_PRAGMA + source  # Source is already double 
    351365    elif dtype == F128: 
     366        fbytes = 16 
    352367        source = _convert_type(source, "long double", "L") 
    353368    else: 
    354369        raise ValueError("Unexpected dtype in source conversion: %s"%dtype) 
    355     return source 
     370    return ("#define FLOAT_SIZE %d\n"%fbytes)+source 
    356371 
    357372 
Note: See TracChangeset for help on using the changeset viewer.