32 #ifdef POK_NEEDS_LIBMATH
35 #include "math_private.h"
37 static float pzerof(
float), qzerof(
float);
42 invsqrtpi= 5.6418961287e-01,
43 tpi = 6.3661974669e-01,
45 R02 = 1.5625000000e-02,
46 R03 = -1.8997929874e-04,
47 R04 = 1.8295404516e-06,
48 R05 = -4.6183270541e-09,
49 S01 = 1.5619102865e-02,
50 S02 = 1.1692678527e-04,
51 S03 = 5.1354652442e-07,
52 S04 = 1.1661400734e-09;
54 static const float zero = 0.0;
57 __ieee754_j0f(
float x)
59 float z, s,c,ss,cc,r,u,v;
64 if(ix>=0x7f800000)
return one/(x*x);
66 if(ix >= 0x40000000) {
73 if ((s*c)<zero) cc = z/ss;
81 if(ix>0x80000000) z = (invsqrtpi*cc)/sqrtf(x);
85 u = pzerof(x); v = qzerof(x);
86 z = invsqrtpi*(u*cc-v*ss)/sqrtf(x);
92 if(ix<0x32000000)
return one;
93 else return one - (float)0.25*x*x;
97 r = z*(R02+z*(R03+z*(R04+z*R05)));
98 s = one+z*(S01+z*(S02+z*(S03+z*S04)));
100 return one + z*((float)-0.25+(r/s));
103 return((one+u)*(one-u)+z*(r/s));
108 u00 = -7.3804296553e-02,
109 u01 = 1.7666645348e-01,
110 u02 = -1.3818567619e-02,
111 u03 = 3.4745343146e-04,
112 u04 = -3.8140706238e-06,
113 u05 = 1.9559013964e-08,
114 u06 = -3.9820518410e-11,
115 v01 = 1.2730483897e-02,
116 v02 = 7.6006865129e-05,
117 v03 = 2.5915085189e-07,
118 v04 = 4.4111031494e-10;
121 __ieee754_y0f(
float x)
123 float z, s,c,ss,cc,u,v;
126 GET_FLOAT_WORD(hx,x);
129 if(ix>=0x7f800000)
return one/(x+x*x);
130 if(ix==0)
return -one/zero;
131 if(hx<0)
return zero/zero;
132 if(ix >= 0x40000000) {
154 if ((s*c)<zero) cc = z/ss;
158 if(ix>0x80000000) z = (invsqrtpi*ss)/sqrtf(x);
162 u = pzerof(x); v = qzerof(x);
163 z = invsqrtpi*(u*ss+v*cc)/sqrtf(x);
168 return(u00 + tpi*__ieee754_logf(x));
171 u = u00+z*(u01+z*(u02+z*(u03+z*(u04+z*(u05+z*u06)))));
172 v = one+z*(v01+z*(v02+z*(v03+z*v04)));
173 return(u/v + tpi*(__ieee754_j0f(x)*__ieee754_logf(x)));
185 static const float pR8[6] = {
193 static const float pS8[5] = {
200 static const float pR5[6] = {
208 static const float pS5[5] = {
216 static const float pR3[6] = {
224 static const float pS3[5] = {
232 static const float pR2[6] = {
240 static const float pS2[5] = {
256 GET_FLOAT_WORD(ix,x);
258 if(ix>=0x41000000) {p = pR8; q= pS8;}
259 else if(ix>=0x40f71c58){p = pR5; q= pS5;}
260 else if(ix>=0x4036db68){p = pR3; q= pS3;}
261 else if(ix>=0x40000000){p = pR2; q= pS2;}
263 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
264 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*q[4]))));
278 static const float qR8[6] = {
286 static const float qS8[6] = {
295 static const float qR5[6] = {
303 static const float qS5[6] = {
312 static const float qR3[6] = {
320 static const float qS3[6] = {
329 static const float qR2[6] = {
337 static const float qS2[6] = {
354 GET_FLOAT_WORD(ix,x);
356 if(ix>=0x41000000) {p = qR8; q= qS8;}
357 else if(ix>=0x40f71c58){p = qR5; q= qS5;}
358 else if(ix>=0x4036db68){p = qR3; q= qS3;}
359 else if(ix>=0x40000000){p = qR2; q= qS2;}
361 r = p[0]+z*(p[1]+z*(p[2]+z*(p[3]+z*(p[4]+z*p[5]))));
362 s = one+z*(q[0]+z*(q[1]+z*(q[2]+z*(q[3]+z*(q[4]+z*q[5])))));
363 return (-(
float).125 + r/s)/x;