Print this page
11210 libm should be cstyle(1ONBLD) clean
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libm/common/Q/__sincosl.c
+++ new/usr/src/lib/libm/common/Q/__sincosl.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.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
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
20 20 */
21 21
22 22 /*
23 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
24 24 */
25 +
25 26 /*
26 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
27 28 * Use is subject to license terms.
28 29 */
29 30
30 31 /*
31 32 * long double __k_sincos(long double x, long double y, long double *c);
32 33 * kernel sincosl function on [-pi/4, pi/4], pi/4 ~ 0.785398164
33 34 * Input x is assumed to be bounded by ~pi/4 in magnitude.
34 35 * Input y is the tail of x.
35 36 * return sinl(x) with *c = cosl(x)
36 37 *
37 38 * Table look up algorithm
38 39 * see __k_sinl and __k_cosl
39 40 */
40 41
41 42 #include "libm.h"
42 43
43 -extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[],
44 - _TBL_cosl_hi[], _TBL_cosl_lo[];
45 -static const long double
46 - one = 1.0L,
44 +extern const long double _TBL_sinl_hi[], _TBL_sinl_lo[], _TBL_cosl_hi[],
45 + _TBL_cosl_lo[];
46 +static const long double one = 1.0L;
47 +
47 48 /*
48 49 * 3 11 -122.32
49 50 * |sin(x) - (x+pp1*x +...+ pp5*x )| <= 2 for |x|<1/64
50 51 */
51 - pp1 = -1.666666666666666666666666666586782940810e-0001L,
52 - pp2 = +8.333333333333333333333003723660929317540e-0003L,
53 - pp3 = -1.984126984126984076045903483778337804470e-0004L,
54 - pp4 = +2.755731922361906641319723106210900949413e-0006L,
55 - pp5 = -2.505198398570947019093998469135012057673e-0008L,
52 +static const long double
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;
58 +
56 59 /*
57 60 * |(sin(x) - (x+p1*x^3+...+p8*x^17)|
58 61 * |------------------------------- | <= 2^-116.17 for |x|<0.1953125
59 62 * | x |
60 63 */
61 - p1 = -1.666666666666666666666666666666211262297e-0001L,
62 - p2 = +8.333333333333333333333333301497876908541e-0003L,
63 - p3 = -1.984126984126984126984041302881180621922e-0004L,
64 - p4 = +2.755731922398589064100587351307269621093e-0006L,
65 - p5 = -2.505210838544163129378906953765595393873e-0008L,
66 - p6 = +1.605904383643244375050998243778534074273e-0010L,
67 - p7 = -7.647162722800685516901456114270824622699e-0013L,
68 - p8 = +2.810046428661902961725428841068844462603e-0015L,
64 +static const long double
65 + p1 = -1.666666666666666666666666666666211262297e-0001L,
66 + p2 = +8.333333333333333333333333301497876908541e-0003L,
67 + p3 = -1.984126984126984126984041302881180621922e-0004L,
68 + p4 = +2.755731922398589064100587351307269621093e-0006L,
69 + p5 = -2.505210838544163129378906953765595393873e-0008L,
70 + p6 = +1.605904383643244375050998243778534074273e-0010L,
71 + p7 = -7.647162722800685516901456114270824622699e-0013L,
72 + p8 = +2.810046428661902961725428841068844462603e-0015L;
73 +
69 74 /*
70 75 * 2 10 -123.84
71 76 * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128
72 77 */
73 - qq1 = -4.999999999999999999999999999999378373641e-0001L,
74 - qq2 = +4.166666666666666666666665478399327703130e-0002L,
75 - qq3 = -1.388888888888888888058211230618051613494e-0003L,
76 - qq4 = +2.480158730156105377771585658905303111866e-0005L,
77 - qq5 = -2.755728099762526325736488376695157008736e-0007L,
78 +static const long double
79 + qq1 = -4.999999999999999999999999999999378373641e-0001L,
80 + qq2 = +4.166666666666666666666665478399327703130e-0002L,
81 + qq3 = -1.388888888888888888058211230618051613494e-0003L,
82 + qq4 = +2.480158730156105377771585658905303111866e-0005L,
83 + qq5 = -2.755728099762526325736488376695157008736e-0007L;
84 +
78 85 /*
79 86 * 2 16 -117.11
80 87 * |cos(x) - (1+q1*x + ... + q8*x )| <= 2 for |x|<= 0.15625
81 88 */
82 - q1 = -4.999999999999999999999999999999756416975e-0001L,
83 - q2 = +4.166666666666666666666666664006066577258e-0002L,
84 - q3 = -1.388888888888888888888877700363937169637e-0003L,
85 - q4 = +2.480158730158730158494468463031814083559e-0005L,
86 - q5 = -2.755731922398586276322819250356005542871e-0007L,
87 - q6 = +2.087675698767424261441959760729854017855e-0009L,
88 - q7 = -1.147074481239662089072452129010790774761e-0011L,
89 - q8 = +4.777761647399651599730663422263531034782e-0014L;
89 +static const long double
90 + q1 = -4.999999999999999999999999999999756416975e-0001L,
91 + q2 = +4.166666666666666666666666664006066577258e-0002L,
92 + q3 = -1.388888888888888888888877700363937169637e-0003L,
93 + q4 = +2.480158730158730158494468463031814083559e-0005L,
94 + q5 = -2.755731922398586276322819250356005542871e-0007L,
95 + q6 = +2.087675698767424261441959760729854017855e-0009L,
96 + q7 = -1.147074481239662089072452129010790774761e-0011L,
97 + q8 = +4.777761647399651599730663422263531034782e-0014L;
90 98
91 99 #define i0 0
92 100
93 101 long double
94 -__k_sincosl(long double x, long double y, long double *c) {
102 +__k_sincosl(long double x, long double y, long double *c)
103 +{
95 104 long double a1, a2, t, t1, t2, z, w;
96 - int *pt = (int *) &t, *px = (int *) &x;
105 + int *pt = (int *)&t, *px = (int *)&x;
97 106 int i, j, hx, ix;
98 107
99 108 t = 1.0L;
100 109 hx = px[i0];
101 110 ix = hx & 0x7fffffff;
111 +
102 112 if (ix < 0x3ffc4000) {
103 - if (ix < 0x3fc60000)
104 - if (((int) x) == 0) {
113 + if (ix < 0x3fc60000) {
114 + if (((int)x) == 0) {
105 115 *c = one;
106 116 return (x);
107 - } /* generate inexact */
117 + } /* generate inexact */
118 + }
119 +
108 120 z = x * x;
109 121
110 122 if (ix < 0x3ff80000) {
111 - *c = one + z * (qq1 + z * (qq2 + z * (qq3 +
112 - z * (qq4 + z * qq5))));
113 - t = z * (p1 + z * (p2 + z * (p3 + z * (p4 +
114 - z * (p5 + z * p6)))));
123 + *c = one + z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 +
124 + z * qq5))));
125 + t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 +
126 + z * p6)))));
115 127 } else {
116 - *c = one + z * (q1 + z * (q2 + z * (q3 + z * (q4 +
117 - z * (q5 + z * (q6 + z * (q7 + z * q8)))))));
128 + *c = one + z * (q1 + z * (q2 + z * (q3 + z * (q4 + z *
129 + (q5 + z * (q6 + z * (q7 + z * q8)))))));
118 130 t = z * (p1 + z * (p2 + z * (p3 + z * (p4 + z * (p5 +
119 - z * (p6 + z * (p7 + z * p8)))))));
131 + z * (p6 + z * (p7 + z * p8)))))));
120 132 }
121 133
122 134 t = y + x * t;
123 135 return (x + t);
124 136 }
137 +
125 138 j = (ix + 0x400) & 0x7ffff800;
126 139 i = (j - 0x3ffc4000) >> 11;
127 140 pt[i0] = j;
141 +
128 142 if (hx > 0)
129 143 x = y - (t - x);
130 144 else
131 145 x = (-y) - (t + x);
146 +
132 147 a1 = _TBL_sinl_hi[i];
133 148 z = x * x;
134 149 t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5))));
135 150 w = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5)))));
136 151 a2 = _TBL_cosl_hi[i];
137 152 t2 = _TBL_cosl_lo[i] - (a1 * w - a2 * t);
138 153 *c = a2 + t2;
139 154 t1 = a2 * w + a1 * t;
140 155 t1 += _TBL_sinl_lo[i];
156 +
141 157 if (hx < 0)
142 158 return (-a1 - t1);
143 159 else
144 160 return (a1 + t1);
145 161 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX