Changeset 994d77f in sasmodels for sasmodels/models/cylinder.c


Ignore:
Timestamp:
Oct 30, 2014 10:33:53 AM (9 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:
ef2861b
Parents:
d087487b
Message:

Convert double to float rather than using real

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/cylinder.c

    r0496031 r994d77f  
    1 real form_volume(real radius, real length); 
    2 real Iq(real q, real sld, real solvent_sld, real radius, real length); 
    3 real Iqxy(real qx, real qy, real sld, real solvent_sld, 
    4     real radius, real length, real theta, real phi); 
     1double form_volume(double radius, double length); 
     2double Iq(double q, double sld, double solvent_sld, double radius, double length); 
     3double Iqxy(double qx, double qy, double sld, double solvent_sld, 
     4    double radius, double length, double theta, double phi); 
    55 
    66// twovd = 2 * volume * delta_rho 
    77// besarg = q * R * sin(alpha) 
    88// siarg = q * L/2 * cos(alpha) 
    9 real _cyl(real twovd, real besarg, real siarg); 
    10 real _cyl(real twovd, real besarg, real siarg) 
     9double _cyl(double twovd, double besarg, double siarg); 
     10double _cyl(double twovd, double besarg, double siarg) 
    1111{ 
    12     const real bj = (besarg == REAL(0.0) ? REAL(0.5) : J1(besarg)/besarg); 
    13     const real si = (siarg == REAL(0.0) ? REAL(1.0) : sin(siarg)/siarg); 
     12    const double bj = (besarg == 0.0 ? 0.5 : J1(besarg)/besarg); 
     13    const double si = (siarg == 0.0 ? 1.0 : sin(siarg)/siarg); 
    1414    return twovd*si*bj; 
    1515} 
    1616 
    17 real form_volume(real radius, real length) 
     17double form_volume(double radius, double length) 
    1818{ 
    1919    return M_PI*radius*radius*length; 
    2020} 
    2121 
    22 real Iq(real q, 
    23     real sld, 
    24     real solvent_sld, 
    25     real radius, 
    26     real length) 
     22double Iq(double q, 
     23    double sld, 
     24    double solvent_sld, 
     25    double radius, 
     26    double length) 
    2727{ 
    28     const real qr = q*radius; 
    29     const real qh = q*REAL(0.5)*length; 
    30     const real twovd = REAL(2.0)*(sld-solvent_sld)*form_volume(radius, length); 
    31     real total = REAL(0.0); 
    32     // real lower=0, upper=M_PI_2; 
     28    const double qr = q*radius; 
     29    const double qh = q*0.5*length; 
     30    const double twovd = 2.0*(sld-solvent_sld)*form_volume(radius, length); 
     31    double total = 0.0; 
     32    // double lower=0, upper=M_PI_2; 
    3333    for (int i=0; i<76 ;i++) { 
    3434        // translate a point in [-1,1] to a point in [lower,upper] 
    35         //const real alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; 
    36         const real alpha = REAL(0.5)*(Gauss76Z[i]*M_PI_2 + M_PI_2); 
    37         real sn, cn; 
     35        //const double alpha = ( Gauss76Z[i]*(upper-lower) + upper + lower )/2.0; 
     36        const double alpha = 0.5*(Gauss76Z[i]*M_PI_2 + M_PI_2); 
     37        double sn, cn; 
    3838        SINCOS(alpha, sn, cn); 
    39         const real fq = _cyl(twovd, qr*sn, qh*cn); 
     39        const double fq = _cyl(twovd, qr*sn, qh*cn); 
    4040        total += Gauss76Wt[i] * fq * fq * sn; 
    4141    } 
    4242    // translate dx in [-1,1] to dx in [lower,upper] 
    43     //const real form = (upper-lower)/2.0*total; 
    44     return REAL(1.0e-4) * total * M_PI_4; 
     43    //const double form = (upper-lower)/2.0*total; 
     44    return 1.0e-4 * total * M_PI_4; 
    4545} 
    4646 
    4747 
    48 real Iqxy(real qx, real qy, 
    49     real sld, 
    50     real solvent_sld, 
    51     real radius, 
    52     real length, 
    53     real theta, 
    54     real phi) 
     48double Iqxy(double qx, double qy, 
     49    double sld, 
     50    double solvent_sld, 
     51    double radius, 
     52    double length, 
     53    double theta, 
     54    double phi) 
    5555{ 
    5656    // TODO: check that radius<0 and length<0 give zero scattering. 
    5757    // This should be the case since the polydispersity weight vector should 
    5858    // be zero length, and this function never called. 
    59     real sn, cn; // slots to hold sincos function output 
     59    double sn, cn; // slots to hold sincos function output 
    6060 
    6161    // Compute angle alpha between q and the cylinder axis 
    6262    SINCOS(theta*M_PI_180, sn, cn); 
    63     const real q = sqrt(qx*qx+qy*qy); 
    64     const real cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 
    65     const real alpha = acos(cos_val); 
     63    const double q = sqrt(qx*qx+qy*qy); 
     64    const double cos_val = cn*cos(phi*M_PI_180)*(qx/q) + sn*(qy/q); 
     65    const double alpha = acos(cos_val); 
    6666 
    67     const real twovd = REAL(2.0)*(sld-solvent_sld)*form_volume(radius, length); 
     67    const double twovd = 2.0*(sld-solvent_sld)*form_volume(radius, length); 
    6868    SINCOS(alpha, sn, cn); 
    69     const real fq = _cyl(twovd, q*radius*sn, q*REAL(0.5)*length*cn); 
    70     return REAL(1.0e-4) * fq * fq; 
     69    const double fq = _cyl(twovd, q*radius*sn, q*0.5*length*cn); 
     70    return 1.0e-4 * fq * fq; 
    7171} 
Note: See TracChangeset for help on using the changeset viewer.