Changeset 4962519 in sasmodels for sasmodels/models/lib


Ignore:
Timestamp:
Oct 14, 2016 6:49:58 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
14838a3
Parents:
a5b6997
Message:

use square and cube instead of pow()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/lib/wrc_cyl.c

    rba32cdd r4962519  
    1414    //return t; 
    1515 
    16     return pow( (1.0 + (x/3.12)*(x/3.12) + 
    17          (x/8.67)*(x/8.67)*(x/8.67)),(0.176/3.0) ); 
     16    return pow(1.0+square(x/3.12)+cube(x/8.67), 0.176/3.0); 
    1817} 
    1918 
     
    2322{ 
    2423    const double r = b/L; 
    25     return (L*b/6.0) * 
    26            (1.0 - r*1.5  + 1.5*r*r - 0.75*r*r*r*(1.0 - exp(-2.0/r))); 
     24    return (L*b/6.0) * (1.0 - r*(1.5 + r*(1.5 + r*0.75*expm1(-2.0/r)))); 
    2725} 
    2826 
     
    4139} 
    4240 
    43 static inline double 
     41static double 
    4442sech_WR(double x) 
    4543{ 
     
    5149{ 
    5250    double C; 
    53     const double onehalf = 1.0/2.0; 
    5451 
    5552    if( L/b > 10.0) { 
     
    8683 
    8784    const double t2 = (2.0*b4*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 
    88          Rg02/b2))*((1.0 + onehalf*(((-1.0) - 
     85         Rg02/b2))*((1.0 + 0.5*(((-1.0) - 
    8986         tanh((-C4 + Rgb/C5))))))); 
    9087 
     
    112109 
    113110    const double t9 = (2.0*b4*(((2.0*q0*Rg2)/b - 
    114          (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*Rg2)/b))*((1.0 + onehalf*(((-1.0) - 
     111         (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*Rg2)/b))*((1.0 + 0.5*(((-1.0) - 
    115112         tanh(((-C4) + Rgb)/C5)))))); 
    116113 
    117114    const double t10 = (8.0*b4*b*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 
    118          Rg02/b2))*((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 
     115         Rg02/b2))*((1.0 + 0.5*(((-1.0) - tanh(((-C4) + 
    119116         Rgb)/C5)))))); 
    120117 
     
    131128 
    132129    const double t14 = (2.0*b4*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 
    133           Rg02/b2))*((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 
     130          Rg02/b2))*((1.0 + 0.5*(((-1.0) - tanh(((-C4) + 
    134131          Rgb)/C5)))))); 
    135132 
     
    140137 
    141138    double yy = (pow(q0,p1)*(((-((b*M_PI)/(L*q0))) +t1/L +t2/(q04*Rg22) + 
    142         onehalf*t3*t4)) + (t5*((pow(q0,(p1 - p2))* 
     139        0.5*t3*t4)) + (t5*((pow(q0,(p1 - p2))* 
    143140        (((-pow(q0,(-p1)))*(((b2*M_PI)/(L*q02) +t6/L +t7/(2.0*C5) - 
    144         t8/(C5*q04*Rg22) + t9/(q04*Rg22) -t10/(q05*Rg22) + onehalf*t11*t12)) - 
     141        t8/(C5*q04*Rg22) + t9/(q04*Rg22) -t10/(q05*Rg22) + 0.5*t11*t12)) - 
    145142        b*p1*pow(q0,((-1.0) - p1))*(((-((b*M_PI)/(L*q0))) + t13/L + 
    146         t14/(q04*Rg22) + onehalf*t15*((1.0 + tanh(((-C4) + 
     143        t14/(q04*Rg22) + 0.5*t15*((1.0 + tanh(((-C4) + 
    147144        Rgb)/C5))))))))))); 
    148145 
     
    154151{ 
    155152    double C; 
    156     const double onehalf = 1.0/2.0; 
    157153 
    158154    if( L/b > 10.0) { 
     
    201197    const double t5 = (2.0*b4*(((2.0*q0*Rg2)/b - 
    202198         (2.0*pow((double)M_E,(-(Rg02/b2)))*q0*Rg2)/b))* 
    203          ((1.0 + onehalf*(((-1.0) - tanh(((-C4) + 
     199         ((1.0 + 0.5*(((-1.0) - tanh(((-C4) + 
    204200         Rgb)/C5))))))/(q04*Rg22); 
    205201 
    206202    const double t6 = (8.0*b4*b*(((-1.0) + pow((double)M_E,(-(Rg02/b2))) + 
    207          Rg02/b2))*((1.0 + onehalf*(((-1) - tanh(((-C4) + 
     203         Rg02/b2))*((1.0 + 0.5*(((-1) - tanh(((-C4) + 
    208204         Rgb)/C5))))))/(q05*Rg22); 
    209205 
     
    219215 
    220216    const double t10 = (2.0*b4*(((-1) + pow((double)M_E,(-(Rg02/b2))) + 
    221           Rg02/b2))*((1.0 + onehalf*(((-1) - tanh(((-C4) + 
     217          Rg02/b2))*((1.0 + 0.5*(((-1) - tanh(((-C4) + 
    222218          Rgb)/C5))))))/(q04*Rg22); 
    223219 
    224220    const double yy = ((-1.0*(t1* ((-pow(q0,-p1)*(((b2*M_PI)/(L*q02) + 
    225          t2 + t3 - t4 + t5 - t6 + onehalf*t7*t8)) - b*p1*pow(q0,((-1.0) - p1))* 
     221         t2 + t3 - t4 + t5 - t6 + 0.5*t7*t8)) - b*p1*pow(q0,((-1.0) - p1))* 
    226222         (((-((b*M_PI)/(L*q0))) + t9 + t10 + 
    227          onehalf*((C3*pow(((Rgb)),((-3.0)/miu)) + 
     223         0.5*((C3*pow(((Rgb)),((-3.0)/miu)) + 
    228224         C2*pow(((Rgb)),((-2.0)/miu)) + 
    229225         C1*pow(((Rgb)),((-1.0)/miu))))* 
Note: See TracChangeset for help on using the changeset viewer.