4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 * Use is subject to license terms.
32 * long double __k_sincos( long double x, long double y, long double *c )
33 * kernel sincosl function on [-pi/4, pi/4], pi/4 ~ 0.785398164
34 * Input x is assumed to be bounded by ~pi/4 in magnitude.
35 * Input y is the tail of x.
36 * return sinl(x) with *c = cosl(x)
38 * Table look up algorithm
39 * see __k_sinl() and __k_cosl()
44 #include <sys/isa_defs.h>
46 extern const long double _TBL_sinl_hi
[], _TBL_sinl_lo
[], _TBL_cosl_hi
[],
48 static const long double
51 * |sin(x) - (x+pp1*x^3+...+pp5*x^11)| <= 2^-122.32 for |x|<1/64
53 pp1
= -1.666666666666666666666666666586782940810e-0001L,
54 pp2
= 8.333333333333333333333003723660929317540e-0003L,
55 pp3
= -1.984126984126984076045903483778337804470e-0004L,
56 pp4
= 2.755731922361906641319723106210900949413e-0006L,
57 pp5
= -2.505198398570947019093998469135012057673e-0008L,
59 * |(sin(x) - (x+p1*x^3+...+p8*x^17)|
60 * |------------------------------- | <= 2^-116.17 for |x|<0.1953125
63 p1
= -1.666666666666666666666666666666211262297e-0001L,
64 p2
= 8.333333333333333333333333301497876908541e-0003L,
65 p3
= -1.984126984126984126984041302881180621922e-0004L,
66 p4
= 2.755731922398589064100587351307269621093e-0006L,
67 p5
= -2.505210838544163129378906953765595393873e-0008L,
68 p6
= 1.605904383643244375050998243778534074273e-0010L,
69 p7
= -7.647162722800685516901456114270824622699e-0013L,
70 p8
= 2.810046428661902961725428841068844462603e-0015L,
73 * |cos(x) - (1+qq1*x^2+...+ qq5*x^10)| <= 2^-123.84 for |x|<=1/128
75 qq1
= -4.999999999999999999999999999999378373641e-0001L,
76 qq2
= 4.166666666666666666666665478399327703130e-0002L,
77 qq3
= -1.388888888888888888058211230618051613494e-0003L,
78 qq4
= 2.480158730156105377771585658905303111866e-0005L,
79 qq5
= -2.755728099762526325736488376695157008736e-0007L,
82 * |cos(x) - (1+q1*x^2+...+ q8*x^16)| <= 2^-117.11 for |x|<= 0.15625
84 q1
= -4.999999999999999999999999999999756416975e-0001L,
85 q2
= 4.166666666666666666666666664006066577258e-0002L,
86 q3
= -1.388888888888888888888877700363937169637e-0003L,
87 q4
= 2.480158730158730158494468463031814083559e-0005L,
88 q5
= -2.755731922398586276322819250356005542871e-0007L,
89 q6
= 2.087675698767424261441959760729854017855e-0009L,
90 q7
= -1.147074481239662089072452129010790774761e-0011L,
91 q8
= 4.777761647399651599730663422263531034782e-0014L;
94 __k_sincosl(long double x
, long double y
, long double *c
) {
95 long double a1
, a2
, t
, t1
, t2
, z
, w
;
96 int *pt
= (int *) &t
, *px
= (int *) &x
;
100 #if defined(__i386) || defined(__amd64)
105 ix
= hx
& 0x7fffffff;
106 if (ix
< 0x3ffc4000) {
108 if (((int) x
) == 0) {
111 } /* generate inexact */
114 if (ix
< 0x3ff80000) {
115 *c
= one
+ z
* (qq1
+ z
* (qq2
+ z
* (qq3
+ z
* (qq4
+
117 t
= z
* (p1
+ z
* (p2
+ z
* (p3
+ z
* (p4
+ z
* (p5
+
120 *c
= one
+ z
* (q1
+ z
* (q2
+ z
* (q3
+ z
* (q4
+ z
*
121 (q5
+ z
* (q6
+ z
* (q7
+ z
* q8
)))))));
122 t
= z
* (p1
+ z
* (p2
+ z
* (p3
+ z
* (p4
+ z
* (p5
+
123 z
* (p6
+ z
* (p7
+ z
* p8
)))))));
129 j
= (ix
+ 0x400) & 0x7ffff800;
130 i
= (j
- 0x3ffc4000) >> 11;
131 #if defined(__i386) || defined(__amd64)
140 a1
= _TBL_sinl_hi
[i
];
142 t
= z
* (qq1
+ z
* (qq2
+ z
* (qq3
+ z
* (qq4
+ z
* qq5
))));
143 w
= x
* (one
+ z
* (pp1
+ z
* (pp2
+ z
* (pp3
+ z
* (pp4
+ z
*
145 a2
= _TBL_cosl_hi
[i
];
146 t2
= _TBL_cosl_lo
[i
] - (a1
* w
- a2
* t
);
148 t1
= a2
* w
+ a1
* t
;
149 t1
+= _TBL_sinl_lo
[i
];