Changeset eb2946f in sasmodels
- Timestamp:
- May 18, 2017 5:10:29 PM (8 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 1b85b55
- Parents:
- 452b168
- Files:
-
- 1 added
- 7 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/lib/sas_3j1x_x.c
r473a9f1 reb2946f 46 46 double sas_3j1x_x(double q) 47 47 { 48 if (q < SPH_J1C_CUTOFF) { 48 // 2017-05-18 PAK - support negative q 49 if (fabs(q) < SPH_J1C_CUTOFF) { 49 50 const double q2 = q*q; 50 51 return (1.0 + q2*(-3./30. + q2*(3./840. + q2*(-3./45360.))));// + q2*(3./3991680.))))); -
sasmodels/models/lib/sas_J0.c
rc8902ac reb2946f 236 236 xx = x; 237 237 238 if( x <= 2.0 ) { 238 // 2017-05-18 PAK - support negative x 239 if( xx <= 2.0 ) { 239 240 z = xx * xx; 240 if( x < 1.0e-3 )241 if( xx < 1.0e-3 ) 241 242 return( 1.0 - 0.25*z ); 242 243 … … 245 246 } 246 247 247 q = 1.0/x ;248 q = 1.0/xx; 248 249 w = sqrt(q); 249 250 -
sasmodels/models/lib/sas_J1.c
r473a9f1 reb2946f 109 109 { 110 110 111 double w, z, p, q, xn ;111 double w, z, p, q, xn, abs_x, sign_x; 112 112 113 113 const double Z1 = 1.46819706421238932572E1; … … 116 116 const double SQ2OPI = 0.79788456080286535588; 117 117 118 w = x; 119 if( x < 0 ) 120 w = -x; 121 122 if( w <= 5.0 ) { 123 z = x * x; 118 // 2017-05-18 PAK - mathematica and mpmath use J1(-x) = -J1(x) 119 if (x < 0) { 120 abs_x = -x; 121 sign_x = -1.0; 122 } else { 123 abs_x = x; 124 sign_x = 1.0; 125 } 126 127 if( abs_x <= 5.0 ) { 128 z = abs_x * abs_x; 124 129 w = polevl( z, RPJ1, 3 ) / p1evl( z, RQJ1, 8 ); 125 w = w * x * (z - Z1) * (z - Z2);126 return( w );130 w = w * abs_x * (z - Z1) * (z - Z2); 131 return( sign_x * w ); 127 132 } 128 133 129 w = 5.0/ x;134 w = 5.0/abs_x; 130 135 z = w * w; 131 132 136 p = polevl( z, PPJ1, 6)/polevl( z, PQJ1, 6 ); 133 137 q = polevl( z, QPJ1, 7)/p1evl( z, QQJ1, 7 ); 134 135 xn = x - THPIO4; 138 xn = abs_x - THPIO4; 136 139 137 140 double sn, cn; … … 139 142 p = p * cn - w * q * sn; 140 143 141 return( p * SQ2OPI / sqrt(x) );144 return( sign_x * p * SQ2OPI / sqrt(abs_x) ); 142 145 } 143 146 … … 179 182 }; 180 183 181 float cephes_j1f(float x )184 float cephes_j1f(float xx) 182 185 { 183 186 184 float x x, w, z, p, q, xn;187 float x, w, z, p, q, xn; 185 188 186 189 const float Z1 = 1.46819706421238932572E1; … … 188 191 189 192 190 xx = x; 191 if( xx < 0 ) 192 xx = -x; 193 194 if( xx <= 2.0 ) { 195 z = xx * xx; 196 p = (z-Z1) * xx * polevl( z, JPJ1, 4 ); 197 return( p ); 193 // 2017-05-18 PAK - mathematica and mpmath use J1(-x) = -J1(x) 194 x = xx; 195 if( x < 0 ) 196 x = -xx; 197 198 if( x <= 2.0 ) { 199 z = x * x; 200 p = (z-Z1) * x * polevl( z, JPJ1, 4 ); 201 return( xx < 0. ? -p : p ); 198 202 } 199 203 … … 204 208 w = q*q; 205 209 xn = q * polevl( w, PH1J1, 7) - THPIO4F; 206 p = p * cos(xn + x x);207 208 return( p);210 p = p * cos(xn + x); 211 212 return( xx < 0. ? -p : p ); 209 213 } 210 214 #endif -
sasmodels/models/lib/sas_erf.c
rb3796fa reb2946f 165 165 // the erf function instead and z < 1.0. 166 166 //return (1.0 - cephes_erf(a)); 167 z = x * x; 168 y = x * polevl(z, TD, 4) / p1evl(z, UD, 5); 169 170 return y; 167 // 2017-05-18 PAK - use erf(a) rather than erf(|a|) 168 z = a * a; 169 y = a * polevl(z, TD, 4) / p1evl(z, UD, 5); 170 171 return 1.0 - y; 171 172 } 172 173 … … 279 280 //is explicit here for the case < 1.0 280 281 //return (1.0 - sas_erf(a)); 281 z = x * x; 282 y = x * polevl( z, TF, 6 ); 283 284 return y; 282 // 2017-05-18 PAK - use erf(a) rather than erf(|a|) 283 z = a * a; 284 y = a * polevl( z, TF, 6 ); 285 286 return 1.0 - y; 285 287 } 286 288
Note: See TracChangeset
for help on using the changeset viewer.