Changeset e3a9733 in sasmodels


Ignore:
Timestamp:
Dec 23, 2015 8:05:05 AM (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:
cde11f0f
Parents:
644430f
Message:

support kahan summation to avoid roundoff error, but don't turn it on

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_template.c

    rc138211 re3a9733  
    55# define USE_OPENCL 
    66#endif 
     7 
     8#define USE_KAHAN_SUMMATION 0 
    79 
    810// If opencl is not available, then we are compiling a C function 
     
    185187    const double qxi = qx[i]; 
    186188    const double qyi = qy[i]; 
     189    #if USE_KAHAN_SUMMATION 
     190    double accumulated_error = 0.0; 
     191    #endif 
    187192#ifdef IQXY_OPEN_LOOPS 
    188193    double ret=0.0, norm=0.0; 
     
    207212        // rather than theta in this correction.  Current code uses cos(theta) 
    208213        // so that values match those of sasview. 
    209       #ifdef IQXY_HAS_THETA 
     214      #if defined(IQXY_HAS_THETA) // && 0 
    210215        const double spherical_correction 
    211           = (Ntheta>1 ? fabs(cos(M_PI_180*theta))*M_PI_2:1.0); 
    212         ret += spherical_correction * weight * scattering; 
     216          = (Ntheta>1 ? fabs(cos(M_PI_180*phi))*M_PI_2:1.0); 
     217        const double next = spherical_correction * weight * scattering; 
    213218      #else 
    214         ret += weight * scattering; 
     219        const double next = weight * scattering; 
     220      #endif 
     221      #if USE_KAHAN_SUMMATION 
     222        const double y = next - accumulated_error; 
     223        const double t = ret + y; 
     224        accumulated_error = (t - ret) - y; 
     225        ret = t; 
     226      #else 
     227        ret += next; 
    215228      #endif 
    216229        norm += weight; 
Note: See TracChangeset for help on using the changeset viewer.