74 #ifdef POK_NEEDS_LIBMATH
77 #include "math_private.h"
79 static double pone(
double), qone(
double);
84 invsqrtpi= 5.64189583547756279280e-01,
85 tpi = 6.36619772367581382433e-01,
87 r00 = -6.25000000000000000000e-02,
88 r01 = 1.40705666955189706048e-03,
89 r02 = -1.59955631084035597520e-05,
90 r03 = 4.96727999609584448412e-08,
91 s01 = 1.91537599538363460805e-02,
92 s02 = 1.85946785588630915560e-04,
93 s03 = 1.17718464042623683263e-06,
94 s04 = 5.04636257076217042715e-09,
95 s05 = 1.23542274426137913908e-11;
97 static const double zero = 0.0;
100 __ieee754_j1(
double x)
102 double z, s,c,ss,cc,r,u,v,y;
107 if(ix>=0x7ff00000)
return one/x;
109 if(ix >= 0x40000000) {
116 if ((s*c)>zero) cc = z/ss;
123 if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(y);
125 u = pone(y); v = qone(y);
126 z = invsqrtpi*(u*cc-v*ss)/sqrt(y);
132 if(huge+x>one)
return 0.5*x;
135 r = z*(r00+z*(r01+z*(r02+z*r03)));
136 s = one+z*(s01+z*(s02+z*(s03+z*(s04+z*s05))));
141 static const double U0[5] = {
142 -1.96057090646238940668e-01,
143 5.04438716639811282616e-02,
144 -1.91256895875763547298e-03,
145 2.35252600561610495928e-05,
146 -9.19099158039878874504e-08,
148 static const double V0[5] = {
149 1.99167318236649903973e-02,
150 2.02552581025135171496e-04,
151 1.35608801097516229404e-06,
152 6.22741452364621501295e-09,
153 1.66559246207992079114e-11,
157 __ieee754_y1(
double x)
159 double z, s,c,ss,cc,u,v;
162 EXTRACT_WORDS(hx,lx,x);
165 if(ix>=0x7ff00000)
return one/(x+x*x);
166 if((ix|lx)==0)
return -one/zero;
167 if(hx<0)
return zero/zero;
168 if(ix >= 0x40000000) {
175 if ((s*c)>zero) cc = z/ss;
189 if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
191 u = pone(x); v = qone(x);
192 z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
200 u = U0[0]+z*(U0[1]+z*(U0[2]+z*(U0[3]+z*U0[4])));
201 v = one+z*(V0[0]+z*(V0[1]+z*(V0[2]+z*(V0[3]+z*V0[4]))));
202 return(x*(u/v) + tpi*(__ieee754_j1(x)*__ieee754_log(x)-one/x));
215 static const double pr8[6] = {
216 0.00000000000000000000e+00,
217 1.17187499999988647970e-01,
218 1.32394806593073575129e+01,
219 4.12051854307378562225e+02,
220 3.87474538913960532227e+03,
221 7.91447954031891731574e+03,
223 static const double ps8[5] = {
224 1.14207370375678408436e+02,
225 3.65093083420853463394e+03,
226 3.69562060269033463555e+04,
227 9.76027935934950801311e+04,
228 3.08042720627888811578e+04,
231 static const double pr5[6] = {
232 1.31990519556243522749e-11,
233 1.17187493190614097638e-01,
234 6.80275127868432871736e+00,
235 1.08308182990189109773e+02,
236 5.17636139533199752805e+02,
237 5.28715201363337541807e+02,
239 static const double ps5[5] = {
240 5.92805987221131331921e+01,
241 9.91401418733614377743e+02,
242 5.35326695291487976647e+03,
243 7.84469031749551231769e+03,
244 1.50404688810361062679e+03,
247 static const double pr3[6] = {
248 3.02503916137373618024e-09,
249 1.17186865567253592491e-01,
250 3.93297750033315640650e+00,
251 3.51194035591636932736e+01,
252 9.10550110750781271918e+01,
253 4.85590685197364919645e+01,
255 static const double ps3[5] = {
256 3.47913095001251519989e+01,
257 3.36762458747825746741e+02,
258 1.04687139975775130551e+03,
259 8.90811346398256432622e+02,
260 1.03787932439639277504e+02,
263 static const double pr2[6] = {
264 1.07710830106873743082e-07,
265 1.17176219462683348094e-01,
266 2.36851496667608785174e+00,
267 1.22426109148261232917e+01,
268 1.76939711271687727390e+01,
269 5.07352312588818499250e+00,
271 static const double ps2[5] = {
272 2.14364859363821409488e+01,
273 1.25290227168402751090e+02,
274 2.32276469057162813669e+02,
275 1.17679373287147100768e+02,
276 8.36463893371618283368e+00,
289 if(ix>=0x40200000) {p = pr8; q= ps8;}
290 else if(ix>=0x40122E8B){p = pr5; q= ps5;}
291 else if(ix>=0x4006DB6D){p = pr3; q= ps3;}
292 else if(ix>=0x40000000){p = pr2; q= ps2;}
294 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
295 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
310 static const double qr8[6] = {
311 0.00000000000000000000e+00,
312 -1.02539062499992714161e-01,
313 -1.62717534544589987888e+01,
314 -7.59601722513950107896e+02,
315 -1.18498066702429587167e+04,
316 -4.84385124285750353010e+04,
318 static const double qs8[6] = {
319 1.61395369700722909556e+02,
320 7.82538599923348465381e+03,
321 1.33875336287249578163e+05,
322 7.19657723683240939863e+05,
323 6.66601232617776375264e+05,
324 -2.94490264303834643215e+05,
327 static const double qr5[6] = {
328 -2.08979931141764104297e-11,
329 -1.02539050241375426231e-01,
330 -8.05644828123936029840e+00,
331 -1.83669607474888380239e+02,
332 -1.37319376065508163265e+03,
333 -2.61244440453215656817e+03,
335 static const double qs5[6] = {
336 8.12765501384335777857e+01,
337 1.99179873460485964642e+03,
338 1.74684851924908907677e+04,
339 4.98514270910352279316e+04,
340 2.79480751638918118260e+04,
341 -4.71918354795128470869e+03,
344 static const double qr3[6] = {
345 -5.07831226461766561369e-09,
346 -1.02537829820837089745e-01,
347 -4.61011581139473403113e+00,
348 -5.78472216562783643212e+01,
349 -2.28244540737631695038e+02,
350 -2.19210128478909325622e+02,
352 static const double qs3[6] = {
353 4.76651550323729509273e+01,
354 6.73865112676699709482e+02,
355 3.38015286679526343505e+03,
356 5.54772909720722782367e+03,
357 1.90311919338810798763e+03,
358 -1.35201191444307340817e+02,
361 static const double qr2[6] = {
362 -1.78381727510958865572e-07,
363 -1.02517042607985553460e-01,
364 -2.75220568278187460720e+00,
365 -1.96636162643703720221e+01,
366 -4.23253133372830490089e+01,
367 -2.13719211703704061733e+01,
369 static const double qs2[6] = {
370 2.95333629060523854548e+01,
371 2.52981549982190529136e+02,
372 7.57502834868645436472e+02,
373 7.39393205320467245656e+02,
374 1.55949003336666123687e+02,
375 -4.95949898822628210127e+00,
388 if(ix>=0x40200000) {p = qr8; q= qs8;}
389 else if(ix>=0x40122E8B){p = qr5; q= qs5;}
390 else if(ix>=0x4006DB6D){p = qr3; q= qs3;}
391 else if(ix>=0x40000000){p = qr2; q= qs2;}
393 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
394 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
395 return (.375 + r/s)/x;