74 #ifdef POK_NEEDS_LIBMATH
77 #include "math_private.h"
79 static double pzero(
double), qzero(
double);
84 invsqrtpi= 5.64189583547756279280e-01,
85 tpi = 6.36619772367581382433e-01,
87 R02 = 1.56249999999999947958e-02,
88 R03 = -1.89979294238854721751e-04,
89 R04 = 1.82954049532700665670e-06,
90 R05 = -4.61832688532103189199e-09,
91 S01 = 1.56191029464890010492e-02,
92 S02 = 1.16926784663337450260e-04,
93 S03 = 5.13546550207318111446e-07,
94 S04 = 1.16614003333790000205e-09;
96 static const double zero = 0.0;
99 __ieee754_j0(
double x)
101 double z, s,c,ss,cc,r,u,v;
106 if(ix>=0x7ff00000)
return one/(x*x);
108 if(ix >= 0x40000000) {
115 if ((s*c)<zero) cc = z/ss;
122 if(ix>0x48000000) z = (invsqrtpi*cc)/sqrt(x);
124 u = pzero(x); v = qzero(x);
125 z = invsqrtpi*(u*cc-v*ss)/sqrt(x);
131 if(ix<0x3e400000)
return one;
132 else return one - 0.25*x*x;
136 r = z*(R02+z*(R03+z*(R04+z*R05)));
137 s = one+z*(S01+z*(S02+z*(S03+z*S04)));
138 if(ix < 0x3FF00000) {
139 return one + z*(-0.25+(r/s));
142 return((one+u)*(one-u)+z*(r/s));
147 u00 = -7.38042951086872317523e-02,
148 u01 = 1.76666452509181115538e-01,
149 u02 = -1.38185671945596898896e-02,
150 u03 = 3.47453432093683650238e-04,
151 u04 = -3.81407053724364161125e-06,
152 u05 = 1.95590137035022920206e-08,
153 u06 = -3.98205194132103398453e-11,
154 v01 = 1.27304834834123699328e-02,
155 v02 = 7.60068627350353253702e-05,
156 v03 = 2.59150851840457805467e-07,
157 v04 = 4.41110311332675467403e-10;
160 __ieee754_y0(
double x)
162 double z, s,c,ss,cc,u,v;
165 EXTRACT_WORDS(hx,lx,x);
168 if(ix>=0x7ff00000)
return one/(x+x*x);
169 if((ix|lx)==0)
return -one/zero;
170 if(hx<0)
return zero/zero;
171 if(ix >= 0x40000000) {
193 if ((s*c)<zero) cc = z/ss;
196 if(ix>0x48000000) z = (invsqrtpi*ss)/sqrt(x);
198 u = pzero(x); v = qzero(x);
199 z = invsqrtpi*(u*ss+v*cc)/sqrt(x);
204 return(u00 + tpi*__ieee754_log(x));
207 u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
208 v = one+z*(v01+z*(v02+z*(v03+z*v04)));
209 return(u/v + tpi*(__ieee754_j0(x)*__ieee754_log(x)));
221 static const double pR8[6] = {
222 0.00000000000000000000e+00,
223 -7.03124999999900357484e-02,
224 -8.08167041275349795626e+00,
225 -2.57063105679704847262e+02,
226 -2.48521641009428822144e+03,
227 -5.25304380490729545272e+03,
229 static const double pS8[5] = {
230 1.16534364619668181717e+02,
231 3.83374475364121826715e+03,
232 4.05978572648472545552e+04,
233 1.16752972564375915681e+05,
234 4.76277284146730962675e+04,
237 static const double pR5[6] = {
238 -1.14125464691894502584e-11,
239 -7.03124940873599280078e-02,
240 -4.15961064470587782438e+00,
241 -6.76747652265167261021e+01,
242 -3.31231299649172967747e+02,
243 -3.46433388365604912451e+02,
245 static const double pS5[5] = {
246 6.07539382692300335975e+01,
247 1.05125230595704579173e+03,
248 5.97897094333855784498e+03,
249 9.62544514357774460223e+03,
250 2.40605815922939109441e+03,
253 static const double pR3[6] = {
254 -2.54704601771951915620e-09,
255 -7.03119616381481654654e-02,
256 -2.40903221549529611423e+00,
257 -2.19659774734883086467e+01,
258 -5.80791704701737572236e+01,
259 -3.14479470594888503854e+01,
261 static const double pS3[5] = {
262 3.58560338055209726349e+01,
263 3.61513983050303863820e+02,
264 1.19360783792111533330e+03,
265 1.12799679856907414432e+03,
266 1.73580930813335754692e+02,
269 static const double pR2[6] = {
270 -8.87534333032526411254e-08,
271 -7.03030995483624743247e-02,
272 -1.45073846780952986357e+00,
273 -7.63569613823527770791e+00,
274 -1.11931668860356747786e+01,
275 -3.23364579351335335033e+00,
277 static const double pS2[5] = {
278 2.22202997532088808441e+01,
279 1.36206794218215208048e+02,
280 2.70470278658083486789e+02,
281 1.53875394208320329881e+02,
282 1.46576176948256193810e+01,
295 if(ix>=0x40200000) {p = pR8; q= pS8;}
296 else if(ix>=0x40122E8B){p = pR5; q= pS5;}
297 else if(ix>=0x4006DB6D){p = pR3; q= pS3;}
298 else if(ix>=0x40000000){p = pR2; q= pS2;}
300 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
301 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
315 static const double qR8[6] = {
316 0.00000000000000000000e+00,
317 7.32421874999935051953e-02,
318 1.17682064682252693899e+01,
319 5.57673380256401856059e+02,
320 8.85919720756468632317e+03,
321 3.70146267776887834771e+04,
323 static const double qS8[6] = {
324 1.63776026895689824414e+02,
325 8.09834494656449805916e+03,
326 1.42538291419120476348e+05,
327 8.03309257119514397345e+05,
328 8.40501579819060512818e+05,
329 -3.43899293537866615225e+05,
332 static const double qR5[6] = {
333 1.84085963594515531381e-11,
334 7.32421766612684765896e-02,
335 5.83563508962056953777e+00,
336 1.35111577286449829671e+02,
337 1.02724376596164097464e+03,
338 1.98997785864605384631e+03,
340 static const double qS5[6] = {
341 8.27766102236537761883e+01,
342 2.07781416421392987104e+03,
343 1.88472887785718085070e+04,
344 5.67511122894947329769e+04,
345 3.59767538425114471465e+04,
346 -5.35434275601944773371e+03,
349 static const double qR3[6] = {
350 4.37741014089738620906e-09,
351 7.32411180042911447163e-02,
352 3.34423137516170720929e+00,
353 4.26218440745412650017e+01,
354 1.70808091340565596283e+02,
355 1.66733948696651168575e+02,
357 static const double qS3[6] = {
358 4.87588729724587182091e+01,
359 7.09689221056606015736e+02,
360 3.70414822620111362994e+03,
361 6.46042516752568917582e+03,
362 2.51633368920368957333e+03,
363 -1.49247451836156386662e+02,
366 static const double qR2[6] = {
367 1.50444444886983272379e-07,
368 7.32234265963079278272e-02,
369 1.99819174093815998816e+00,
370 1.44956029347885735348e+01,
371 3.16662317504781540833e+01,
372 1.62527075710929267416e+01,
374 static const double qS2[6] = {
375 3.03655848355219184498e+01,
376 2.69348118608049844624e+02,
377 8.44783757595320139444e+02,
378 8.82935845112488550512e+02,
379 2.12666388511798828631e+02,
380 -5.31095493882666946917e+00,
393 if(ix>=0x40200000) {p = qR8; q= qS8;}
394 else if(ix>=0x40122E8B){p = qR5; q= qS5;}
395 else if(ix>=0x4006DB6D){p = qR3; q= qS3;}
396 else if(ix>=0x40000000){p = qR2; q= qS2;}
398 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
399 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
400 return (-.125 + r/s)/x;