32 #ifdef POK_NEEDS_LIBMATH
35 #include "math_private.h"
39 half= 5.0000000000e-01,
40 one = 1.0000000000e+00,
41 two = 2.0000000000e+00,
43 erx = 8.4506291151e-01,
47 efx = 1.2837916613e-01,
48 efx8= 1.0270333290e+00,
49 pp0 = 1.2837916613e-01,
50 pp1 = -3.2504209876e-01,
51 pp2 = -2.8481749818e-02,
52 pp3 = -5.7702702470e-03,
53 pp4 = -2.3763017452e-05,
54 qq1 = 3.9791721106e-01,
55 qq2 = 6.5022252500e-02,
56 qq3 = 5.0813062117e-03,
57 qq4 = 1.3249473704e-04,
58 qq5 = -3.9602282413e-06,
62 pa0 = -2.3621185683e-03,
63 pa1 = 4.1485610604e-01,
64 pa2 = -3.7220788002e-01,
65 pa3 = 3.1834661961e-01,
66 pa4 = -1.1089469492e-01,
67 pa5 = 3.5478305072e-02,
68 pa6 = -2.1663755178e-03,
69 qa1 = 1.0642088205e-01,
70 qa2 = 5.4039794207e-01,
71 qa3 = 7.1828655899e-02,
72 qa4 = 1.2617121637e-01,
73 qa5 = 1.3637083583e-02,
74 qa6 = 1.1984500103e-02,
78 ra0 = -9.8649440333e-03,
79 ra1 = -6.9385856390e-01,
80 ra2 = -1.0558626175e+01,
81 ra3 = -6.2375331879e+01,
82 ra4 = -1.6239666748e+02,
83 ra5 = -1.8460508728e+02,
84 ra6 = -8.1287437439e+01,
85 ra7 = -9.8143291473e+00,
86 sa1 = 1.9651271820e+01,
87 sa2 = 1.3765776062e+02,
88 sa3 = 4.3456588745e+02,
89 sa4 = 6.4538726807e+02,
90 sa5 = 4.2900814819e+02,
91 sa6 = 1.0863500214e+02,
92 sa7 = 6.5702495575e+00,
93 sa8 = -6.0424413532e-02,
97 rb0 = -9.8649431020e-03,
98 rb1 = -7.9928326607e-01,
99 rb2 = -1.7757955551e+01,
100 rb3 = -1.6063638306e+02,
101 rb4 = -6.3756646729e+02,
102 rb5 = -1.0250950928e+03,
103 rb6 = -4.8351919556e+02,
104 sb1 = 3.0338060379e+01,
105 sb2 = 3.2579251099e+02,
106 sb3 = 1.5367296143e+03,
107 sb4 = 3.1998581543e+03,
108 sb5 = 2.5530502930e+03,
109 sb6 = 4.7452853394e+02,
110 sb7 = -2.2440952301e+01;
116 float R,S,P,Q,s,y,z,r;
117 GET_FLOAT_WORD(hx,x);
120 i = ((uint32_t)hx>>31)<<1;
121 return (
float)(1-i)+one/x;
124 if(ix < 0x3f580000) {
125 if(ix < 0x31800000) {
128 return (
float)0.125*((float)8.0*x+efx8*x);
132 r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
133 s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
137 if(ix < 0x3fa00000) {
139 P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
140 Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
141 if(hx>=0)
return erx + P/Q;
else return -erx - P/Q;
143 if (ix >= 0x40c00000) {
144 if(hx>=0)
return one-tiny;
else return tiny-one;
149 R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
150 ra5+s*(ra6+s*ra7))))));
151 S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
152 sa5+s*(sa6+s*(sa7+s*sa8)))))));
154 R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
156 S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
157 sb5+s*(sb6+s*sb7))))));
159 GET_FLOAT_WORD(ix,x);
160 SET_FLOAT_WORD(z,ix&0xfffff000);
161 r = __ieee754_expf(-z*z-(
float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
162 if(hx>=0)
return one-r/x;
else return r/x-one;
169 float R,S,P,Q,s,y,z,r;
170 GET_FLOAT_WORD(hx,x);
174 return (
float)(((uint32_t)hx>>31)<<1)+one/x;
177 if(ix < 0x3f580000) {
181 r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
182 s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
184 if(hx < 0x3e800000) {
192 if(ix < 0x3fa00000) {
194 P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
195 Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
197 z = one-erx;
return z - P/Q;
199 z = erx+P/Q;
return one+z;
202 if (ix < 0x41e00000) {
206 R=ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
207 ra5+s*(ra6+s*ra7))))));
208 S=one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
209 sa5+s*(sa6+s*(sa7+s*sa8)))))));
211 if(hx<0&&ix>=0x40c00000)
return two-tiny;
212 R=rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
214 S=one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
215 sb5+s*(sb6+s*sb7))))));
217 GET_FLOAT_WORD(ix,x);
218 SET_FLOAT_WORD(z,ix&0xfffff000);
219 r = __ieee754_expf(-z*z-(
float)0.5625)*
220 __ieee754_expf((z-x)*(z+x)+R/S);
221 if(hx>0)
return r/x;
else return two-r/x;
223 if(hx>0)
return tiny*tiny;
else return two-tiny;