Print this page
5262 libm needs to be carefully unifdef'd
5268 libm doesn't need to hide symbols which are already local
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/Q/tanhl.c
+++ new/usr/src/lib/libm/common/Q/tanhl.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
↓ open down ↓ |
19 lines elided |
↑ open up ↑ |
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 25 /*
26 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 27 * Use is subject to license terms.
28 28 */
29 29
30 -#if defined(ELFOBJ)
31 30 #pragma weak tanhl = __tanhl
32 -#endif
33 31
34 32 /*
35 33 * tanhl(x) returns the hyperbolic tangent of x
36 34 *
37 35 * Method :
38 36 * 1. reduce x to non-negative: tanhl(-x) = - tanhl(x).
39 37 * 2.
40 38 * 0 < x <= small : tanhl(x) := x
41 39 * -expm1l(-2x)
42 40 * small < x <= 1 : tanhl(x) := --------------
43 41 * expm1l(-2x) + 2
44 42 * 2
45 43 * 1 <= x <= threshold : tanhl(x) := 1 - ---------------
46 44 * expm1l(2x) + 2
47 45 * threshold < x <= INF : tanhl(x) := 1.
48 46 *
49 47 * where
50 48 * single : small = 1.e-5 threshold = 11.0
51 49 * double : small = 1.e-10 threshold = 22.0
52 50 * quad : small = 1.e-20 threshold = 45.0
53 51 *
54 52 * Note: threshold was chosen so that
55 53 * fl(1.0+2/(expm1(2*threshold)+2)) == 1.
56 54 *
57 55 * Special cases:
58 56 * tanhl(NaN) is NaN;
59 57 * only tanhl(0.0)=0.0 is exact for finite argument.
60 58 */
61 59
62 60 #include "libm.h"
63 61 #include "longdouble.h"
64 62
65 63 static const long double small = 1.0e-20L, one = 1.0, two = 2.0,
66 64 #ifndef lint
67 65 big = 1.0e+20L,
68 66 #endif
69 67 threshold = 45.0L;
70 68
71 69 long double
72 70 tanhl(long double x) {
73 71 long double t, y, z;
74 72 int signx;
75 73 volatile long double dummy;
76 74
77 75 if (isnanl(x))
78 76 return (x + x); /* x is NaN */
79 77 signx = signbitl(x);
80 78 t = fabsl(x);
81 79 z = one;
82 80 if (t <= threshold) {
83 81 if (t > one)
84 82 z = one - two / (expm1l(t + t) + two);
85 83 else if (t > small) {
86 84 y = expm1l(-t - t);
87 85 z = -y / (y + two);
88 86 } else {
89 87 #ifndef lint
90 88 dummy = t + big;
91 89 /* inexact if t != 0 */
92 90 #endif
93 91 return (x);
94 92 }
95 93 } else if (!finitel(t))
96 94 return (copysignl(one, x));
97 95 else
98 96 return (signx ? -z + small * small : z - small * small);
99 97 return (signx ? -z : z);
100 98 }
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX