Mercurial > hg > CbC > CbC_gcc
comparison libquadmath/math/sinq_kernel.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 /* Quad-precision floating point sine on <-pi/4,pi/4>. | 1 /* Quad-precision floating point sine on <-pi/4,pi/4>. |
2 Copyright (C) 1999 Free Software Foundation, Inc. | 2 Copyright (C) 1999-2018 Free Software Foundation, Inc. |
3 This file is part of the GNU C Library. | 3 This file is part of the GNU C Library. |
4 Contributed by Jakub Jelinek <jj@ultra.linux.cz> | 4 Contributed by Jakub Jelinek <jj@ultra.linux.cz> |
5 | 5 |
6 The GNU C Library is free software; you can redistribute it and/or | 6 The GNU C Library is free software; you can redistribute it and/or |
7 modify it under the terms of the GNU Lesser General Public | 7 modify it under the terms of the GNU Lesser General Public |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 Lesser General Public License for more details. | 14 Lesser General Public License for more details. |
15 | 15 |
16 You should have received a copy of the GNU Lesser General Public | 16 You should have received a copy of the GNU Lesser General Public |
17 License along with the GNU C Library; if not, write to the Free | 17 License along with the GNU C Library; if not, see |
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | 18 <http://www.gnu.org/licenses/>. */ |
19 02111-1307 USA. */ | |
20 | 19 |
21 #include "quadmath-imp.h" | 20 #include "quadmath-imp.h" |
22 | 21 |
23 static const __float128 c[] = { | 22 static const __float128 c[] = { |
24 #define ONE c[0] | 23 #define ONE c[0] |
68 -1.98412698412698412697726277416810661E-04Q, /* bff2a01a01a01a01a019e7121e080d88 */ | 67 -1.98412698412698412697726277416810661E-04Q, /* bff2a01a01a01a01a019e7121e080d88 */ |
69 2.75573192239848624174178393552189149E-06Q, /* 3fec71de3a556c640c6aaa51aa02ab41 */ | 68 2.75573192239848624174178393552189149E-06Q, /* 3fec71de3a556c640c6aaa51aa02ab41 */ |
70 -2.50521016467996193495359189395805639E-08Q, /* bfe5ae644ee90c47dc71839de75b2787 */ | 69 -2.50521016467996193495359189395805639E-08Q, /* bfe5ae644ee90c47dc71839de75b2787 */ |
71 }; | 70 }; |
72 | 71 |
73 #define SINCOSQ_COS_HI 0 | 72 #define SINCOSL_COS_HI 0 |
74 #define SINCOSQ_COS_LO 1 | 73 #define SINCOSL_COS_LO 1 |
75 #define SINCOSQ_SIN_HI 2 | 74 #define SINCOSL_SIN_HI 2 |
76 #define SINCOSQ_SIN_LO 3 | 75 #define SINCOSL_SIN_LO 3 |
77 extern const __float128 __sincosq_table[]; | 76 extern const __float128 __sincosq_table[]; |
78 | 77 |
79 __float128 | 78 __float128 |
80 __quadmath_kernel_sinq (__float128 x, __float128 y, int iy) | 79 __quadmath_kernel_sinq(__float128 x, __float128 y, int iy) |
81 { | 80 { |
82 __float128 h, l, z, sin_l, cos_l_m1; | 81 __float128 h, l, z, sin_l, cos_l_m1; |
83 int64_t ix; | 82 int64_t ix; |
84 uint32_t tix, hix, index; | 83 uint32_t tix, hix, index; |
85 GET_FLT128_MSW64 (ix, x); | 84 GET_FLT128_MSW64 (ix, x); |
99 z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8))))))))); | 98 z*(SIN5+z*(SIN6+z*(SIN7+z*SIN8))))))))); |
100 } | 99 } |
101 else | 100 else |
102 { | 101 { |
103 /* So that we don't have to use too large polynomial, we find | 102 /* So that we don't have to use too large polynomial, we find |
104 l and h such that x = l + h, where fabsl(l) <= 1.0/256 with 83 | 103 l and h such that x = l + h, where fabsq(l) <= 1.0/256 with 83 |
105 possible values for h. We look up cosq(h) and sinq(h) in | 104 possible values for h. We look up cosq(h) and sinq(h) in |
106 pre-computed tables, compute cosq(l) and sinq(l) using a | 105 pre-computed tables, compute cosq(l) and sinq(l) using a |
107 Chebyshev polynomial of degree 10(11) and compute | 106 Chebyshev polynomial of degree 10(11) and compute |
108 sinq(h+l) = sinq(h)cosq(l) + cosq(h)sinq(l). */ | 107 sinq(h+l) = sinq(h)cosq(l) + cosq(h)sinq(l). */ |
109 index = 0x3ffe - (tix >> 16); | 108 index = 0x3ffe - (tix >> 16); |
123 else | 122 else |
124 l = x - h; | 123 l = x - h; |
125 z = l * l; | 124 z = l * l; |
126 sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5))))); | 125 sin_l = l*(ONE+z*(SSIN1+z*(SSIN2+z*(SSIN3+z*(SSIN4+z*SSIN5))))); |
127 cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5)))); | 126 cos_l_m1 = z*(SCOS1+z*(SCOS2+z*(SCOS3+z*(SCOS4+z*SCOS5)))); |
128 z = __sincosq_table [index + SINCOSQ_SIN_HI] | 127 z = __sincosq_table [index + SINCOSL_SIN_HI] |
129 + (__sincosq_table [index + SINCOSQ_SIN_LO] | 128 + (__sincosq_table [index + SINCOSL_SIN_LO] |
130 + (__sincosq_table [index + SINCOSQ_SIN_HI] * cos_l_m1) | 129 + (__sincosq_table [index + SINCOSL_SIN_HI] * cos_l_m1) |
131 + (__sincosq_table [index + SINCOSQ_COS_HI] * sin_l)); | 130 + (__sincosq_table [index + SINCOSL_COS_HI] * sin_l)); |
132 return (ix < 0) ? -z : z; | 131 return (ix < 0) ? -z : z; |
133 } | 132 } |
134 } | 133 } |