Changeset 39c2de9 in sasmodels


Ignore:
Timestamp:
Aug 29, 2018 9:53:55 AM (6 years ago)
Author:
GitHub <noreply@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
992299c
Parents:
0168844 (diff), 70530778 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Paul Kienzle <pkienzle@…> (08/29/18 09:53:55)
git-committer:
GitHub <noreply@…> (08/29/18 09:53:55)
Message:

Merge pull request #77 from SasView?/2d_speckles

avoid cancellation error causing NaN values to appear in 2D patterns

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/kernel_iq.c

    r7c35fda r70530778  
    8484  out_spin = clip(out_spin, 0.0, 1.0); 
    8585  // Previous version of this function took the square root of the weights, 
    86   // under the assumption that  
     86  // under the assumption that 
    8787  // 
    8888  //     w*I(q, rho1, rho2, ...) = I(q, sqrt(w)*rho1, sqrt(w)*rho2, ...) 
     
    188188    QACRotation *rotation, 
    189189    double qx, double qy, 
    190     double *qa_out, double *qc_out) 
     190    double *qab_out, double *qc_out) 
    191191{ 
     192    // Indirect calculation of qab, from qab^2 = |q|^2 - qc^2 
    192193    const double dqc = rotation->R31*qx + rotation->R32*qy; 
    193     // Indirect calculation of qab, from qab^2 = |q|^2 - qc^2 
    194     const double dqa = sqrt(-dqc*dqc + qx*qx + qy*qy); 
    195  
    196     *qa_out = dqa; 
     194    const double dqab_sq = -dqc*dqc + qx*qx + qy*qy; 
     195    //*qab_out = sqrt(fabs(dqab_sq)); 
     196    *qab_out = dqab_sq > 0.0 ? sqrt(dqab_sq) : 0.0; 
    197197    *qc_out = dqc; 
    198198} 
Note: See TracChangeset for help on using the changeset viewer.