Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/sinhq.c @ 145:1830386684a0
gcc-9.2.0
author | anatofuz |
---|---|
date | Thu, 13 Feb 2020 11:34:05 +0900 |
parents | 04ced10e8804 |
children |
comparison
equal
deleted
inserted
replaced
131:84e7813d76e9 | 145:1830386684a0 |
---|---|
1 /* sinhq.c -- __float128 version of e_sinh.c. | 1 /* e_sinhl.c -- long double version of e_sinh.c. |
2 * Conversion to __float128 by Ulrich Drepper, | 2 * Conversion to long double by Ulrich Drepper, |
3 * Cygnus Support, drepper@cygnus.com. | 3 * Cygnus Support, drepper@cygnus.com. |
4 */ | 4 */ |
5 | 5 |
6 /* | 6 /* |
7 * ==================================================== | 7 * ==================================================== |
12 * software is freely granted, provided that this notice | 12 * software is freely granted, provided that this notice |
13 * is preserved. | 13 * is preserved. |
14 * ==================================================== | 14 * ==================================================== |
15 */ | 15 */ |
16 | 16 |
17 /* Changes for 128-bit __float128 are | 17 /* Changes for 128-bit long double are |
18 Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov> | 18 Copyright (C) 2001 Stephen L. Moshier <moshier@na-net.ornl.gov> |
19 and are incorporated herein by permission of the author. The author | 19 and are incorporated herein by permission of the author. The author |
20 reserves the right to distribute this material elsewhere under different | 20 reserves the right to distribute this material elsewhere under different |
21 copying permissions. These modifications are distributed here under | 21 copying permissions. These modifications are distributed here under |
22 the following terms: | 22 the following terms: |
23 | 23 |
24 This library is free software; you can redistribute it and/or | 24 This library is free software; you can redistribute it and/or |
25 modify it under the terms of the GNU Lesser General Public | 25 modify it under the terms of the GNU Lesser General Public |
26 License as published by the Free Software Foundation; either | 26 License as published by the Free Software Foundation; either |
30 but WITHOUT ANY WARRANTY; without even the implied warranty of | 30 but WITHOUT ANY WARRANTY; without even the implied warranty of |
31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 31 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
32 Lesser General Public License for more details. | 32 Lesser General Public License for more details. |
33 | 33 |
34 You should have received a copy of the GNU Lesser General Public | 34 You should have received a copy of the GNU Lesser General Public |
35 License along with this library; if not, write to the Free Software | 35 License along with this library; if not, see |
36 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | 36 <http://www.gnu.org/licenses/>. */ |
37 | 37 |
38 /* sinhq(x) | 38 /* sinhq(x) |
39 * Method : | 39 * Method : |
40 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 | 40 * mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2 |
41 * 1. Replace x by |x| (sinhq(-x) = -sinhq(x)). | 41 * 1. Replace x by |x| (sinhl(-x) = -sinhl(x)). |
42 * 2. | 42 * 2. |
43 * E + E/(E+1) | 43 * E + E/(E+1) |
44 * 0 <= x <= 25 : sinhq(x) := --------------, E=expm1q(x) | 44 * 0 <= x <= 25 : sinhl(x) := --------------, E=expm1q(x) |
45 * 2 | 45 * 2 |
46 * | 46 * |
47 * 25 <= x <= lnovft : sinhq(x) := expq(x)/2 | 47 * 25 <= x <= lnovft : sinhl(x) := expq(x)/2 |
48 * lnovft <= x <= ln2ovft: sinhq(x) := expq(x/2)/2 * expq(x/2) | 48 * lnovft <= x <= ln2ovft: sinhl(x) := expq(x/2)/2 * expq(x/2) |
49 * ln2ovft < x : sinhq(x) := x*shuge (overflow) | 49 * ln2ovft < x : sinhl(x) := x*shuge (overflow) |
50 * | 50 * |
51 * Special cases: | 51 * Special cases: |
52 * sinhq(x) is |x| if x is +INF, -INF, or NaN. | 52 * sinhl(x) is |x| if x is +INF, -INF, or NaN. |
53 * only sinhq(0)=0 is exact for finite x. | 53 * only sinhl(0)=0 is exact for finite x. |
54 */ | 54 */ |
55 | 55 |
56 #include "quadmath-imp.h" | 56 #include "quadmath-imp.h" |
57 | 57 |
58 static const __float128 one = 1.0, shuge = 1.0e4931Q, | 58 static const __float128 one = 1.0, shuge = 1.0e4931Q, |
59 ovf_thresh = 1.1357216553474703894801348310092223067821E4Q; | 59 ovf_thresh = 1.1357216553474703894801348310092223067821E4Q; |
60 | 60 |
61 __float128 | 61 __float128 |
62 sinhq (__float128 x) | 62 sinhq (__float128 x) |
63 { | 63 { |
64 __float128 t, w, h; | 64 __float128 t, w, h; |
72 | 72 |
73 /* x is INF or NaN */ | 73 /* x is INF or NaN */ |
74 if (ix >= 0x7fff0000) | 74 if (ix >= 0x7fff0000) |
75 return x + x; | 75 return x + x; |
76 | 76 |
77 h = 0.5Q; | 77 h = 0.5; |
78 if (jx & 0x80000000) | 78 if (jx & 0x80000000) |
79 h = -h; | 79 h = -h; |
80 | 80 |
81 /* Absolute value of x. */ | 81 /* Absolute value of x. */ |
82 u.words32.w0 = ix; | 82 u.words32.w0 = ix; |
90 if (shuge + x > one) | 90 if (shuge + x > one) |
91 return x; /* sinh(tiny) = tiny with inexact */ | 91 return x; /* sinh(tiny) = tiny with inexact */ |
92 } | 92 } |
93 t = expm1q (u.value); | 93 t = expm1q (u.value); |
94 if (ix < 0x3fff0000) | 94 if (ix < 0x3fff0000) |
95 return h * (2.0Q * t - t * t / (t + one)); | 95 return h * (2.0 * t - t * t / (t + one)); |
96 return h * (t + t / (t + one)); | 96 return h * (t + t / (t + one)); |
97 } | 97 } |
98 | 98 |
99 /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */ | 99 /* |x| in [40, log(maxdouble)] return 0.5*exp(|x|) */ |
100 if (ix <= 0x400c62e3) /* 11356.375 */ | 100 if (ix <= 0x400c62e3) /* 11356.375 */ |
102 | 102 |
103 /* |x| in [log(maxdouble), overflowthreshold] | 103 /* |x| in [log(maxdouble), overflowthreshold] |
104 Overflow threshold is log(2 * maxdouble). */ | 104 Overflow threshold is log(2 * maxdouble). */ |
105 if (u.value <= ovf_thresh) | 105 if (u.value <= ovf_thresh) |
106 { | 106 { |
107 w = expq (0.5Q * u.value); | 107 w = expq (0.5 * u.value); |
108 t = h * w; | 108 t = h * w; |
109 return t * w; | 109 return t * w; |
110 } | 110 } |
111 | 111 |
112 /* |x| > overflowthreshold, sinhq(x) overflow */ | 112 /* |x| > overflowthreshold, sinhl(x) overflow */ |
113 return x * shuge; | 113 return x * shuge; |
114 } | 114 } |