Changeset eb2946f in sasmodels for sasmodels/models/lib/sas_J1.c
- Timestamp:
- May 18, 2017 5:10:29 PM (7 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.