Changeset 82d239a in sasmodels


Ignore:
Timestamp:
Nov 25, 2015 1:08:03 PM (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:
38d8774
Parents:
dc056b9
Message:

minor performance improvement for bcc/fcc by precalculating trig

Location:
sasmodels/models
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/bcc.c

    r6137124 r82d239a  
    2222double _BCCeval(double Theta, double Phi, double temp1, double temp3) { 
    2323 
    24         double temp6,temp7,temp8,temp9,temp10; 
    2524        double result; 
     25        double sin_theta,cos_theta,sin_phi,cos_phi; 
     26        SINCOS(Theta, sin_theta, cos_theta); 
     27        SINCOS(Phi, sin_phi, cos_phi); 
    2628 
    27         temp6 = sin(Theta); 
    28         temp7 = sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)+cos(Theta); 
    29         temp8 = -1.0*sin(Theta)*cos(Phi)-sin(Theta)*sin(Phi)+cos(Theta); 
    30         temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi)-cos(Theta); 
    31         temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9))); 
    32         result = pow(1.0-(temp10*temp10),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10))); 
     29        const double temp6 =  sin_theta; 
     30        const double temp7 =  sin_theta*cos_phi + sin_theta*sin_phi + cos_theta; 
     31        const double temp8 = -sin_theta*cos_phi - sin_theta*sin_phi + cos_theta; 
     32        const double temp9 = -sin_theta*cos_phi + sin_theta*sin_phi - cos_theta; 
     33        const double temp10 = exp((-1.0/8.0)*temp1*(temp7*temp7 + temp8*temp8 + temp9*temp9)); 
     34        result = pow(1.0-(temp10*temp10),3)*temp6 
     35            / ( (1.0 - 2.0*temp10*cos(0.5*temp3*temp7) + temp10*temp10) 
     36              * (1.0 - 2.0*temp10*cos(0.5*temp3*temp8) + temp10*temp10) 
     37              * (1.0 - 2.0*temp10*cos(0.5*temp3*temp9) + temp10*temp10)); 
    3338 
    3439        return (result); 
  • sasmodels/models/fcc.c

    r6137124 r82d239a  
    2222double _FCCeval(double Theta, double Phi, double temp1, double temp3) { 
    2323 
    24         double temp6,temp7,temp8,temp9,temp10; 
    2524        double result; 
     25        double sin_theta,cos_theta,sin_phi,cos_phi; 
     26        SINCOS(Theta, sin_theta, cos_theta); 
     27        SINCOS(Phi, sin_phi, cos_phi); 
    2628 
    27         temp6 = sin(Theta); 
    28         temp7 = sin(Theta)*sin(Phi)+cos(Theta); 
    29         temp8 = -1.0*sin(Theta)*cos(Phi)+cos(Theta); 
    30         temp9 = -1.0*sin(Theta)*cos(Phi)+sin(Theta)*sin(Phi); 
    31         temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9))); 
    32         result = pow((1.0-(temp10*temp10)),3)*temp6/((1.0-2.0*temp10*cos(0.5*temp3*(temp7))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp8))+(temp10*temp10))*(1.0-2.0*temp10*cos(0.5*temp3*(temp9))+(temp10*temp10))); 
     29        const double temp6 =  sin_theta; 
     30        const double temp7 =  sin_theta*sin_phi + cos_theta; 
     31        const double temp8 = -sin_theta*cos_phi + cos_theta; 
     32        const double temp9 = -sin_theta*cos_phi + sin_theta*sin_phi; 
     33 
     34        const double temp10 = exp((-1.0/8.0)*temp1*((temp7*temp7)+(temp8*temp8)+(temp9*temp9))); 
     35        result = pow((1.0-(temp10*temp10)),3)*temp6 
     36            / ( (1.0 - 2.0*temp10*cos(0.5*temp3*temp7) + temp10*temp10) 
     37              * (1.0 - 2.0*temp10*cos(0.5*temp3*temp8) + temp10*temp10) 
     38              * (1.0 - 2.0*temp10*cos(0.5*temp3*temp9) + temp10*temp10)); 
    3339 
    3440        return (result); 
Note: See TracChangeset for help on using the changeset viewer.