1: 2: 3:
4:
5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15:
16: #include "math.h"
17: #include "math_private.h"
18:
19: static const float
20: one = 1.0000000000e+00,
21: huge = 1.000e+30,
22: pio2_hi = 1.5707962513e+00,
23: pio2_lo = 7.5497894159e-08,
24: pio4_hi = 7.8539818525e-01,
25:
26: pS0 = 1.6666667163e-01,
27: pS1 = -3.2556581497e-01,
28: pS2 = 2.0121252537e-01,
29: pS3 = -4.0055535734e-02,
30: pS4 = 7.9153501429e-04,
31: pS5 = 3.4793309169e-05,
32: qS1 = -2.4033949375e+00,
33: qS2 = 2.0209457874e+00,
34: qS3 = -6.8828397989e-01,
35: qS4 = 7.7038154006e-02;
36:
37: float
38: asinf(float x)
39: {
40: float t,w,p,q,c,r,s;
41: int32_t hx,ix;
42: GET_FLOAT_WORD(hx,x);
43: ix = hx&0x7fffffff;
44: if(ix==0x3f800000) {
45:
46: return x*pio2_hi+x*pio2_lo;
47: } else if(ix> 0x3f800000) {
48: return (x-x)/(x-x);
49: } else if (ix<0x3f000000) {
50: if(ix<0x32000000) {
51: if(huge+x>one) return x;
52: } else
53: t = x*x;
54: p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
55: q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
56: w = p/q;
57: return x+x*w;
58: }
59:
60: w = one-fabsf(x);
61: t = w*(float)0.5;
62: p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
63: q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
64: s = sqrtf(t);
65: if(ix>=0x3F79999A) {
66: w = p/q;
67: t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo);
68: } else {
69: int32_t iw;
70: w = s;
71: GET_FLOAT_WORD(iw,w);
72: SET_FLOAT_WORD(w,iw&0xfffff000);
73: c = (t-w*w)/(s+w);
74: r = p/q;
75: p = (float)2.0*s*r-(pio2_lo-(float)2.0*c);
76: q = pio4_hi-(float)2.0*w;
77: t = pio4_hi-(p-q);
78: }
79: if(hx>0) return t; else return -t;
80: }