Changeset 398aa94 in sasmodels


Ignore:
Timestamp:
Apr 6, 2016 5:19:56 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:
ee8f734
Parents:
3fb3449
Message:

protect against zero norm

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    r5ff1b03 r398aa94  
    8484 
    8585    const double norm = CALL_VOLUME(local_values); 
     86    const double scale = values[0]; 
     87    const double background = values[1]; 
    8688    #ifdef USE_OPENMP 
    8789    #pragma omp parallel for 
     
    9092    for (int i=0; i < nq; i++) { 
    9193      double scattering = CALL_IQ(q, i, local_values); 
    92       result[i] = values[0]*scattering/norm + values[1]; 
     94      result[i] = (norm>0. ? scale*scattering/norm + background : background); 
    9395    } 
    9496    return; 
     
    203205  } 
    204206 
    205   // Make normalization available for the next round 
     207  // Accumulate norm. 
    206208  result[nq] += norm; 
    207209 
    208210  // End of the PD loop we can normalize 
    209211  if (pd_stop >= problem->total_pd) { 
     212    const double scale = values[0]; 
     213    const double background = values[1]; 
    210214    #ifdef USE_OPENMP 
    211215    #pragma omp parallel for 
    212216    #endif 
    213217    for (int i=0; i < nq; i++) { 
    214       result[i] = values[0]*result[i]/norm + values[1]; 
     218      result[i] = (norm>0. ? scale*scattering/norm + background : background); 
    215219    } 
    216220  } 
Note: See TracChangeset for help on using the changeset viewer.