Print this page
11210 libm should be cstyle(1ONBLD) clean
*** 20,37 ****
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __atan = atan
! /* INDENT OFF */
/*
* atan(x)
* Accurate Table look-up algorithm with polynomial approximation in
* partially product form.
*
--- 20,38 ----
*/
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
+
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma weak __atan = atan
!
/*
* atan(x)
* Accurate Table look-up algorithm with polynomial approximation in
* partially product form.
*
*** 77,100 ****
* j,x
*
* Accuracy: Maximum error observed is bounded by 0.6 ulp after testing
* more than 10 million random arguments
*/
- /* INDENT ON */
#include "libm.h"
#include "libm_protos.h"
extern const double _TBL_atan[];
static const double g[] = {
! /* one = */ 1.0,
! /* p1 = */ 8.02176624254765935351230154992663301527500152588e-0002,
! /* p2 = */ 1.27223421700559402580665846471674740314483642578e+0000,
! /* p3 = */ -1.20606901800503640842521235754247754812240600586e+0000,
! /* p4 = */ -2.36088967922325565496066701598465442657470703125e+0000,
! /* p5 = */ 1.38345799501389166152875986881554126739501953125e+0000,
! /* p6 = */ 1.06742368078953453469637224770849570631980895996e+0000,
/* q1 = */ -1.42796626333911796935538518482644576579332351685e-0001,
/* q2 = */ 3.51427110447873227059810477159863497078605962912e+0000,
/* q3 = */ 5.92129112708164262457444237952586263418197631836e-0001,
/* q4 = */ -1.99272234785683144409063061175402253866195678711e+0000,
/* pio2hi */ 1.570796326794896558e+00,
--- 78,102 ----
* j,x
*
* Accuracy: Maximum error observed is bounded by 0.6 ulp after testing
* more than 10 million random arguments
*/
#include "libm.h"
#include "libm_protos.h"
extern const double _TBL_atan[];
+
static const double g[] = {
! /* one = */
! 1.0,
! /* p1 = */8.02176624254765935351230154992663301527500152588e-0002,
! /* p2 = */1.27223421700559402580665846471674740314483642578e+0000,
! /* p3 = */-1.20606901800503640842521235754247754812240600586e+0000,
! /* p4 = */-2.36088967922325565496066701598465442657470703125e+0000,
! /* p5 = */1.38345799501389166152875986881554126739501953125e+0000,
! /* p6 = */1.06742368078953453469637224770849570631980895996e+0000,
/* q1 = */ -1.42796626333911796935538518482644576579332351685e-0001,
/* q2 = */ 3.51427110447873227059810477159863497078605962912e+0000,
/* q3 = */ 5.92129112708164262457444237952586263418197631836e-0001,
/* q4 = */ -1.99272234785683144409063061175402253866195678711e+0000,
/* pio2hi */ 1.570796326794896558e+00,
*** 119,197 ****
#define pio2lo g[12]
#define t1 g[13]
#define t2 g[14]
#define t3 g[15]
-
double
! atan(double x) {
double y, z, r, p, s;
int ix, lx, hx, j;
! hx = ((int *) &x)[HIWORD];
! lx = ((int *) &x)[LOWORD];
ix = hx & ~0x80000000;
j = ix >> 20;
/* for |x| < 1/8 */
if (j < 0x3fc) {
if (j < 0x3f5) { /* when |x| < 2**(-prec/6-2) */
! if (j < 0x3e3) { /* if |x| < 2**(-prec/2-2) */
! return ((int) x == 0 ? x : one);
! }
if (j < 0x3f1) { /* if |x| < 2**(-prec/4-1) */
return (x + (x * t1) * (x * x));
} else { /* if |x| < 2**(-prec/6-2) */
z = x * x;
s = t2 * x;
return (x + (t3 + z) * (s * z));
}
}
! z = x * x; s = p1 * x;
return (x + ((s * z) * (p2 + z * (p3 + z))) *
(((p4 + z) + z * z) * (p5 + z * (p6 + z))));
}
/* for |x| >= 8.0 */
if (j >= 0x402) {
if (j < 0x436) {
r = one / x;
if (hx >= 0) {
! y = pio2hi; p = pio2lo;
} else {
! y = -pio2hi; p = -pio2lo;
}
if (ix < 0x40504000) { /* x < 65 */
z = r * r;
s = p1 * r;
! return (y + ((p - r) - ((s * z) *
! (p2 + z * (p3 + z))) *
! (((p4 + z) + z * z) *
(p5 + z * (p6 + z)))));
} else if (j < 0x412) {
z = r * r;
! return (y + (p - ((q1 * r) * (q4 + z)) *
! (q2 + z * (q3 + z))));
! } else
return (y + (p - r));
} else {
if (j >= 0x7ff) /* x is inf or NaN */
if (((ix - 0x7ff00000) | lx) != 0)
#if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
return (ix >= 0x7ff80000 ? x : x - x);
/* assumes sparc-like QNaN */
#else
return (x - x);
#endif
y = -pio2lo;
return (hx >= 0 ? pio2hi - y : y - pio2hi);
}
} else { /* now x is between 1/8 and 8 */
double *w, w0, w1, s, z;
! w = (double *) _TBL_atan + (((ix - 0x3fc00000) >> 16) << 1);
! w0 = (hx >= 0)? w[0] : -w[0];
s = (x - w0) / (one + x * w0);
! w1 = (hx >= 0)? w[1] : -w[1];
z = s * s;
return (((q1 * s) * (q4 + z)) * (q2 + z * (q3 + z)) + w1);
}
}
--- 121,207 ----
#define pio2lo g[12]
#define t1 g[13]
#define t2 g[14]
#define t3 g[15]
double
! atan(double x)
! {
double y, z, r, p, s;
int ix, lx, hx, j;
! hx = ((int *)&x)[HIWORD];
! lx = ((int *)&x)[LOWORD];
ix = hx & ~0x80000000;
j = ix >> 20;
/* for |x| < 1/8 */
if (j < 0x3fc) {
if (j < 0x3f5) { /* when |x| < 2**(-prec/6-2) */
! if (j < 0x3e3) /* if |x| < 2**(-prec/2-2) */
! return ((int)x == 0 ? x : one);
!
if (j < 0x3f1) { /* if |x| < 2**(-prec/4-1) */
return (x + (x * t1) * (x * x));
} else { /* if |x| < 2**(-prec/6-2) */
z = x * x;
s = t2 * x;
return (x + (t3 + z) * (s * z));
}
}
!
! z = x * x;
! s = p1 * x;
return (x + ((s * z) * (p2 + z * (p3 + z))) *
(((p4 + z) + z * z) * (p5 + z * (p6 + z))));
}
/* for |x| >= 8.0 */
if (j >= 0x402) {
if (j < 0x436) {
r = one / x;
+
if (hx >= 0) {
! y = pio2hi;
! p = pio2lo;
} else {
! y = -pio2hi;
! p = -pio2lo;
}
+
if (ix < 0x40504000) { /* x < 65 */
z = r * r;
s = p1 * r;
! return (y + ((p - r) - ((s * z) * (p2 + z *
! (p3 + z))) * (((p4 + z) + z * z) *
(p5 + z * (p6 + z)))));
} else if (j < 0x412) {
z = r * r;
! return (y + (p - ((q1 * r) * (q4 + z)) * (q2 +
! z * (q3 + z))));
! } else {
return (y + (p - r));
+ }
} else {
if (j >= 0x7ff) /* x is inf or NaN */
if (((ix - 0x7ff00000) | lx) != 0)
#if defined(FPADD_TRAPS_INCOMPLETE_ON_NAN)
return (ix >= 0x7ff80000 ? x : x - x);
+
/* assumes sparc-like QNaN */
#else
return (x - x);
#endif
y = -pio2lo;
return (hx >= 0 ? pio2hi - y : y - pio2hi);
}
} else { /* now x is between 1/8 and 8 */
double *w, w0, w1, s, z;
!
! w = (double *)_TBL_atan + (((ix - 0x3fc00000) >> 16) << 1);
! w0 = (hx >= 0) ? w[0] : -w[0];
s = (x - w0) / (one + x * w0);
! w1 = (hx >= 0) ? w[1] : -w[1];
z = s * s;
return (((q1 * s) * (q4 + z)) * (q2 + z * (q3 + z)) + w1);
}
}