`11210 libm should be cstyle(1ONBLD) clean`
 ``` `````` 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 24 */ 25 /* 26 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 27 * Use is subject to license terms. 28 */ 29 30 /* INDENT OFF */ 31 /* 32 * __k_tanl( long double x; long double y; int k ) 33 * kernel tan/cotan 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 * Input k indicate -- tan if k=0; else -1/tan 37 * 38 * Table look up algorithm 39 * 1. by tan(-x) = -tan(x), need only to consider positive x 40 * 2. if x < 5/32 = [0x3ffc4000, 0] = 0.15625 , then 41 * if x < 2^-57 (hx < 0x3fc40000 0), set w=x with inexact if x != 0 42 * else 43 * z = x*x; 44 * w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6)))))) 45 * return (k == 0 ? w : 1/w); 46 * 3. else 47 * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) 48 * lt = 0 49 * i = (hy-0x3ffc4000)>>11; (i<=64) 50 * x' = (x - t)+y (|x'| ~<= 2^-7) `````` 54 * We have 55 * sin(x')+tan(t)*(tan(t)*sin(x')) 56 * = tan(t) + ------------------------------- for k=0 57 * cos(x') - tan(t)*sin(x') 58 * 59 * cos(x') - tan(t)*sin(x') 60 * = - -------------------------------------- for k=1 61 * tan(t) + tan(t)*(cos(x')-1) + sin(x') 62 * 63 * 64 * where tan(t) is from the table, 65 * sin(x') = x + pp1*x^3 + ...+ pp5*x^11 66 * cos(x') = 1 + qq1*x^2 + ...+ qq5*x^10 67 */ 68 69 #include "libm.h" 70 71 #include 72 73 extern const long double _TBL_tanl_hi[], _TBL_tanl_lo[]; 74 static const long double 75 one = 1.0, 76 /* 77 * |sin(x) - (x+pp1*x^3+...+ pp5*x^11)| <= 2^-122.32 for |x|<1/64 78 */ 79 pp1 = -1.666666666666666666666666666586782940810e-0001L, 80 pp2 = 8.333333333333333333333003723660929317540e-0003L, 81 pp3 = -1.984126984126984076045903483778337804470e-0004L, 82 pp4 = 2.755731922361906641319723106210900949413e-0006L, 83 pp5 = -2.505198398570947019093998469135012057673e-0008L, 84 /* 85 * 2 10 -123.84 86 * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 87 */ 88 qq1 = -4.999999999999999999999999999999378373641e-0001L, 89 qq2 = 4.166666666666666666666665478399327703130e-0002L, 90 qq3 = -1.388888888888888888058211230618051613494e-0003L, 91 qq4 = 2.480158730156105377771585658905303111866e-0005L, 92 qq5 = -2.755728099762526325736488376695157008736e-0007L, 93 /* 94 * |tan(x) - (x+t1*x^3+...+t6*x^13)| 95 * |------------------------------ | <= 2^-59.73 for |x|<0.15625 96 * | x | 97 */ 98 t1 = 3.333333333333333333333333333333423342490e-0001L, 99 t2 = 1.333333333333333333333333333093838744537e-0001L, 100 t3 = 5.396825396825396825396827906318682662250e-0002L, 101 t4 = 2.186948853615520282185576976994418486911e-0002L, 102 t5 = 8.863235529902196573354554519991152936246e-0003L, 103 t6 = 3.592128036572480064652191427543994878790e-0003L, 104 t7 = 1.455834387051455257856833807581901305474e-0003L, 105 t8 = 5.900274409318599857829983256201725587477e-0004L, 106 t9 = 2.391291152117265181501116961901122362937e-0004L, 107 t10 = 9.691533169382729742394024173194981882375e-0005L, 108 t11 = 3.927994733186415603228178184225780859951e-0005L, 109 t12 = 1.588300018848323824227640064883334101288e-0005L, 110 t13 = 6.916271223396808311166202285131722231723e-0006L; 111 /* INDENT ON */ 112 long double 113 __k_tanl(long double x, long double y, int k) { 114 long double a, t, z, w = 0.0, s, c; 115 int *pt = (int *) &t, *px = (int *) &x; 116 int i, j, hx, ix; 117 118 t = 1.0; 119 #if defined(__i386) || defined(__amd64) 120 XTOI(px, hx); 121 #else 122 hx = px[0]; 123 #endif 124 ix = hx & 0x7fffffff; 125 if (ix < 0x3ffc4000) { 126 if (ix < 0x3fc60000) { 127 if ((i = (int) x) == 0) /* generate inexact */ 128 w = x; 129 } else { 130 z = x * x; 131 if (ix < 0x3ff30000) /* 2**-12 */ 132 t = z * (t1 + z * (t2 + z * (t3 + z * t4))); 133 else 134 t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + 135 z * (t5 + z * (t6 + z * (t7 + z * 136 (t8 + z * (t9 + z * (t10 + z * (t11 + 137 z * (t12 + z * t13)))))))))))); 138 t = y + x * t; 139 w = x + t; 140 } 141 return (k == 0 ? w : -one / w); 142 } 143 j = (ix + 0x400) & 0x7ffff800; 144 i = (j - 0x3ffc4000) >> 11; 145 #if defined(__i386) || defined(__amd64) 146 ITOX(j, pt); 147 #else 148 pt[0] = j; 149 #endif 150 if (hx > 0) 151 x = y - (t - x); 152 else 153 x = (-y) - (t + x); 154 a = _TBL_tanl_hi[i]; 155 z = x * x; 156 /* cos(x)-1 */ 157 t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); 158 /* sin(x) */ 159 s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * 160 pp5))))); 161 if (k == 0) { 162 w = a * s; 163 t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); 164 return (hx < 0 ? -a - t : a + t); 165 } else { 166 w = s + a * t; 167 c = w + _TBL_tanl_lo[i]; 168 z = (one - (a * s - t)); 169 return (hx >= 0 ? z / (-a - c) : z / (a + c)); 170 } 171 } ``` ``` `````` 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2011 Nexenta Systems, Inc. All rights reserved. 24 */ 25 26 /* 27 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 28 * Use is subject to license terms. 29 */ 30 31 32 /* 33 * __k_tanl( long double x; long double y; int k ) 34 * kernel tan/cotan function on [-pi/4, pi/4], pi/4 ~ 0.785398164 35 * Input x is assumed to be bounded by ~pi/4 in magnitude. 36 * Input y is the tail of x. 37 * Input k indicate -- tan if k=0; else -1/tan 38 * 39 * Table look up algorithm 40 * 1. by tan(-x) = -tan(x), need only to consider positive x 41 * 2. if x < 5/32 = [0x3ffc4000, 0] = 0.15625 , then 42 * if x < 2^-57 (hx < 0x3fc40000 0), set w=x with inexact if x != 0 43 * else 44 * z = x*x; 45 * w = x + (y+(x*z)*(t1+z*(t2+z*(t3+z*(t4+z*(t5+z*t6)))))) 46 * return (k == 0 ? w : 1/w); 47 * 3. else 48 * ht = (hx + 0x400)&0x7ffff800 (round x to a break point t) 49 * lt = 0 50 * i = (hy-0x3ffc4000)>>11; (i<=64) 51 * x' = (x - t)+y (|x'| ~<= 2^-7) `````` 55 * We have 56 * sin(x')+tan(t)*(tan(t)*sin(x')) 57 * = tan(t) + ------------------------------- for k=0 58 * cos(x') - tan(t)*sin(x') 59 * 60 * cos(x') - tan(t)*sin(x') 61 * = - -------------------------------------- for k=1 62 * tan(t) + tan(t)*(cos(x')-1) + sin(x') 63 * 64 * 65 * where tan(t) is from the table, 66 * sin(x') = x + pp1*x^3 + ...+ pp5*x^11 67 * cos(x') = 1 + qq1*x^2 + ...+ qq5*x^10 68 */ 69 70 #include "libm.h" 71 72 #include 73 74 extern const long double _TBL_tanl_hi[], _TBL_tanl_lo[]; 75 static const long double one = 1.0; 76 77 /* 78 * |sin(x) - (x+pp1*x^3+...+ pp5*x^11)| <= 2^-122.32 for |x|<1/64 79 */ 80 static const long double 81 pp1 = -1.666666666666666666666666666586782940810e-0001L, 82 pp2 = 8.333333333333333333333003723660929317540e-0003L, 83 pp3 = -1.984126984126984076045903483778337804470e-0004L, 84 pp4 = 2.755731922361906641319723106210900949413e-0006L, 85 pp5 = -2.505198398570947019093998469135012057673e-0008L; 86 87 /* 88 * 2 10 -123.84 89 * |cos(x) - (1+qq1*x +...+ qq5*x )| <= 2 for |x|<=1/128 90 */ 91 static const long double 92 qq1 = -4.999999999999999999999999999999378373641e-0001L, 93 qq2 = 4.166666666666666666666665478399327703130e-0002L, 94 qq3 = -1.388888888888888888058211230618051613494e-0003L, 95 qq4 = 2.480158730156105377771585658905303111866e-0005L, 96 qq5 = -2.755728099762526325736488376695157008736e-0007L; 97 98 /* 99 * |tan(x) - (x+t1*x^3+...+t6*x^13)| 100 * |------------------------------ | <= 2^-59.73 for |x|<0.15625 101 * | x | 102 */ 103 static const long double 104 t1 = 3.333333333333333333333333333333423342490e-0001L, 105 t2 = 1.333333333333333333333333333093838744537e-0001L, 106 t3 = 5.396825396825396825396827906318682662250e-0002L, 107 t4 = 2.186948853615520282185576976994418486911e-0002L, 108 t5 = 8.863235529902196573354554519991152936246e-0003L, 109 t6 = 3.592128036572480064652191427543994878790e-0003L, 110 t7 = 1.455834387051455257856833807581901305474e-0003L, 111 t8 = 5.900274409318599857829983256201725587477e-0004L, 112 t9 = 2.391291152117265181501116961901122362937e-0004L, 113 t10 = 9.691533169382729742394024173194981882375e-0005L, 114 t11 = 3.927994733186415603228178184225780859951e-0005L, 115 t12 = 1.588300018848323824227640064883334101288e-0005L, 116 t13 = 6.916271223396808311166202285131722231723e-0006L; 117 118 119 long double 120 __k_tanl(long double x, long double y, int k) 121 { 122 long double a, t, z, w = 0.0, s, c; 123 int *pt = (int *)&t, *px = (int *)&x; 124 int i, j, hx, ix; 125 126 t = 1.0; 127 #if defined(__i386) || defined(__amd64) 128 XTOI(px, hx); 129 #else 130 hx = px[0]; 131 #endif 132 ix = hx & 0x7fffffff; 133 134 if (ix < 0x3ffc4000) { 135 if (ix < 0x3fc60000) { 136 if ((i = (int)x) == 0) /* generate inexact */ 137 w = x; 138 } else { 139 z = x * x; 140 141 if (ix < 0x3ff30000) { /* 2**-12 */ 142 t = z * (t1 + z * (t2 + z * (t3 + z * t4))); 143 } else { 144 t = z * (t1 + z * (t2 + z * (t3 + z * (t4 + z * 145 (t5 + z * (t6 + z * (t7 + z * (t8 + z * 146 (t9 + z * (t10 + z * (t11 + z * (t12 + z * 147 t13)))))))))))); 148 } 149 150 t = y + x * t; 151 w = x + t; 152 } 153 154 return (k == 0 ? w : -one / w); 155 } 156 157 j = (ix + 0x400) & 0x7ffff800; 158 i = (j - 0x3ffc4000) >> 11; 159 #if defined(__i386) || defined(__amd64) 160 ITOX(j, pt); 161 #else 162 pt[0] = j; 163 #endif 164 165 if (hx > 0) 166 x = y - (t - x); 167 else 168 x = (-y) - (t + x); 169 170 a = _TBL_tanl_hi[i]; 171 z = x * x; 172 /* cos(x)-1 */ 173 t = z * (qq1 + z * (qq2 + z * (qq3 + z * (qq4 + z * qq5)))); 174 /* sin(x) */ 175 s = x * (one + z * (pp1 + z * (pp2 + z * (pp3 + z * (pp4 + z * pp5))))); 176 177 if (k == 0) { 178 w = a * s; 179 t = _TBL_tanl_lo[i] + (s + a * w) / (one - (w - t)); 180 return (hx < 0 ? -a - t : a + t); 181 } else { 182 w = s + a * t; 183 c = w + _TBL_tanl_lo[i]; 184 z = (one - (a * s - t)); 185 return (hx >= 0 ? z / (-a - c) : z / (a + c)); 186 } 187 } ```