s_tanhl.c (a48e1f224c561c156d130496638b5defbb3081d0) s_tanhl.c (1531aa5f6a264a372718b83500f957f703797b41)
1/* from: FreeBSD: head/lib/msun/src/s_tanhl.c XXX */
2
3/* @(#)s_tanh.c 5.1 93/09/24 */
4/*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 *
8 * Developed at SunPro, a Sun Microsystems, Inc. business.

--- 72 unchanged lines hidden (view full) ---

81T31 = -1.0407567231003314e-6, /* -0x1176041e656869.0p-72 */
82T33 = 3.4744117554063574e-7; /* 0x1750fe732cab9c.0p-74 */
83#endif /* LDBL_MANT_DIG == 64 */
84
85static inline long double
86divl(long double a, long double b, long double c, long double d,
87 long double e, long double f)
88{
1/* from: FreeBSD: head/lib/msun/src/s_tanhl.c XXX */
2
3/* @(#)s_tanh.c 5.1 93/09/24 */
4/*
5 * ====================================================
6 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
7 *
8 * Developed at SunPro, a Sun Microsystems, Inc. business.

--- 72 unchanged lines hidden (view full) ---

81T31 = -1.0407567231003314e-6, /* -0x1176041e656869.0p-72 */
82T33 = 3.4744117554063574e-7; /* 0x1750fe732cab9c.0p-74 */
83#endif /* LDBL_MANT_DIG == 64 */
84
85static inline long double
86divl(long double a, long double b, long double c, long double d,
87 long double e, long double f)
88{
89 long double inv, r, w;
89 long double inv, r;
90 float fr, fw;
90 float fr, fw;
91 uint32_t hx;
92
93 _2sumF(a, c);
94 b = b + c;
95 _2sumF(d, f);
96 e = e + f;
97
98 inv = 1 / (d + e);
99

--- 23 unchanged lines hidden (view full) ---

123 /* x is INF or NaN */
124 if(ix>=0x7fff) {
125 if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */
126 else return one/x-one; /* tanh(NaN) = NaN */
127 }
128
129 ENTERI();
130
91
92 _2sumF(a, c);
93 b = b + c;
94 _2sumF(d, f);
95 e = e + f;
96
97 inv = 1 / (d + e);
98

--- 23 unchanged lines hidden (view full) ---

122 /* x is INF or NaN */
123 if(ix>=0x7fff) {
124 if (jx>=0) return one/x+one; /* tanh(+-inf)=+-1 */
125 else return one/x-one; /* tanh(NaN) = NaN */
126 }
127
128 ENTERI();
129
131 if (fabsl(x) < 40) { /* |x|<40 */
130 /* |x| < 40 */
131 if (ix < 0x4004 || fabsl(x) < 40) { /* |x|<40 */
132 if (__predict_false(ix<BIAS-(LDBL_MANT_DIG+1)/2)) { /* |x|<TINY */
133 /* tanh(+-0) = +0; tanh(tiny) = tiny(-+) with inexact: */
134 return (x == 0 ? x : (0x1p200 * x - x) * 0x1p-200);
135 }
132 if (__predict_false(ix<BIAS-(LDBL_MANT_DIG+1)/2)) { /* |x|<TINY */
133 /* tanh(+-0) = +0; tanh(tiny) = tiny(-+) with inexact: */
134 return (x == 0 ? x : (0x1p200 * x - x) * 0x1p-200);
135 }
136 if (fabsl(x) < 0.25) { /* |x|<0.25 */
136 if (ix<0x3ffd) { /* |x|<0.25 */
137 x2 = x*x;
138#if LDBL_MANT_DIG == 64
139 x4 = x2*x2;
140 RETURNI(((T19*x2 + T17)*x4 + (T15*x2 + T13))*(x2*x*x2*x4*x4) +
141 ((T11*x2 + T9)*x4 + (T7*x2 + T5))*(x2*x*x2) +
142 T3*(x2*x) + x);
143#elif LDBL_MANT_DIG == 113
144 dx2 = x2;
137 x2 = x*x;
138#if LDBL_MANT_DIG == 64
139 x4 = x2*x2;
140 RETURNI(((T19*x2 + T17)*x4 + (T15*x2 + T13))*(x2*x*x2*x4*x4) +
141 ((T11*x2 + T9)*x4 + (T7*x2 + T5))*(x2*x*x2) +
142 T3*(x2*x) + x);
143#elif LDBL_MANT_DIG == 113
144 dx2 = x2;
145#if 0
145 RETURNI(((((((((((((((T33*dx2 + T31)*dx2 + T29)*dx2 + T27)*dx2 +
146 T25)*x2 + T23)*x2 + T21)*x2 + T19)*x2 + T17)*x2 +
147 T15)*x2 + T13)*x2 + T11)*x2 + T9)*x2 + T7)*x2 + T5)*
148 (x2*x*x2) +
149 T3*(x2*x) + x);
146 RETURNI(((((((((((((((T33*dx2 + T31)*dx2 + T29)*dx2 + T27)*dx2 +
147 T25)*x2 + T23)*x2 + T21)*x2 + T19)*x2 + T17)*x2 +
148 T15)*x2 + T13)*x2 + T11)*x2 + T9)*x2 + T7)*x2 + T5)*
149 (x2*x*x2) +
150 T3*(x2*x) + x);
151#else
152 long double q = ((((((((((((((T33*dx2 + T31)*dx2 + T29)*dx2 + T27)*dx2 +
153 T25)*x2 + T23)*x2 + T21)*x2 + T19)*x2 + T17)*x2 +
154 T15)*x2 + T13)*x2 + T11)*x2 + T9)*x2 + T7)*x2 + T5)*
155 (x2*x*x2);
156 RETURNI(q + T3*(x2*x) + x);
150#endif
157#endif
158#endif
151 }
152 k_hexpl(2*fabsl(x), &hi, &lo);
159 }
160 k_hexpl(2*fabsl(x), &hi, &lo);
153 if (fabsl(x) < 1.5) /* |x|<1.5 */
161 if (ix<0x4001 && fabsl(x) < 1.5) /* |x|<1.5 */
154 z = divl(hi, lo, -0.5, hi, lo, 0.5);
155 else
156 z = one - one/(lo+0.5+hi);
157 /* |x| >= 40, return +-1 */
158 } else {
159 z = one - tiny; /* raise inexact flag */
160 }
161 s = 1;
162 if (jx<0) s = -1;
163 RETURNI(s*z);
164}
162 z = divl(hi, lo, -0.5, hi, lo, 0.5);
163 else
164 z = one - one/(lo+0.5+hi);
165 /* |x| >= 40, return +-1 */
166 } else {
167 z = one - tiny; /* raise inexact flag */
168 }
169 s = 1;
170 if (jx<0) s = -1;
171 RETURNI(s*z);
172}