#ifdef __APPLE_CC__
#if __APPLE_CC__ > 930
#include "fp_private.h"
#include "fenv_private.h"
extern const unsigned short SqrtTable[];
static const double k2ToM26 = 1.490116119384765625e-8; static const double kPiBy2 = 1.570796326794896619231322; static const double kPiBy2Tail = 6.1232339957367660e-17; static const double kMinNormal = 2.2250738585072014e-308;
const static double a14 = 0.03085091303188211304259;
const static double a13 =-0.02425125216179617744614;
const static double a12 = 0.02273334623573271023373;
const static double a11 = 0.0002983797813053653120360;
const static double a10 = 0.008819738782817955152102;
const static double a9 = 0.008130738583790024803650;
const static double a8 = 0.009793486386035222577675;
const static double a7 = 0.01154901189590083099584;
const static double a6 = 0.01396501522140471126730;
const static double a5 = 0.01735275722383019335276;
const static double a4 = 0.02237215928757573539490;
const static double a3 = 0.03038194444121688698408;
const static double a2 = 0.04464285714288482921087;
const static double a1 = 0.07499999999999990640378;
const static double a0 = 0.1666666666666666667191;
const static double aa11 = 0.0002983797813053653120360;
const static double aa10 = 0.008819738782817955152102;
const static double aa9 = 0.008130738583790024803650;
const static double aa8 = 0.009793486386035222577675;
const static double aa7 = 0.01154901189590083099584;
const static double aa6 = 0.01396501522140471126730;
const static double aa5 = 0.01735275722383019335276;
const static double aa4 = 0.02237215928757573539490;
const static double aa3 = 0.03038194444121688698408;
const static double aa2 = 0.04464285714288482921087;
const static double aa1 = 0.07499999999999990640378;
const static double aa0 = 0.1666666666666666667191;
static const hexdouble kInfinityu = HEXDOUBLE(0x7ff00000, 0x00000000);
static const hexdouble kPiu = HEXDOUBLE(0x400921fb, 0x54442d18);
#define INVERSE_TRIGONOMETRIC_NAN "34"
double asin (double x)
{
hexdouble cD, yD ,gD ,fpenv;
double absx, x2, x3, x4, temp1, temp2, u, v;
double g, y, d, y2, e;
int index;
unsigned long ghead, yhead, rnddir;
if (x != x) return ( copysign ( nan ( INVERSE_TRIGONOMETRIC_NAN ), x ) );
absx = __fabs(x);
fegetenvd (fpenv.d); fesetenvd (0.0);
cD.d = 0.5 - 0.5*absx;
x2 = x*x;
if (absx <= 0.5)
{ if (absx < k2ToM26)
{ if (absx == 0.0)
{ fesetenvd (fpenv.d);
return (x);
}
rnddir = fpenv.i.lo & 0x3ul; fpenv.i.lo |= FE_INEXACT; yD.d = x;
if (((rnddir == 3ul) && (x < 0.0)) || ((rnddir == 2) && (x > 0.0)))
{
yD.i.lo += 1ul;
if (yD.i.lo == 0ul)
yD.i.hi += 1ul;
absx = __fabs(yD.d);
}
if (absx < kMinNormal) fpenv.i.lo |= FE_UNDERFLOW; fesetenvd (fpenv.d); return (yD.d); }
temp1 = a14*x2 + a13;
x4 = x2*x2; fpenv.i.lo |= FE_INEXACT; temp1 = temp1*x4 + a11;
temp2 = a12*x4 + a10;
temp1 = temp1*x4 + a9;
temp2 = temp2*x4 + a8;
temp1 = temp1*x4 + a7;
temp2 = temp2*x4 + a6;
temp1 = temp1*x4 + a5;
temp2 = temp2*x4 + a4;
temp1 = temp1*x4 + a3;
temp2 = temp2*x4 + a2;
temp1 = temp1*x4 + a1;
x3 = x*x2;
temp1 = a0 + x2*(temp2*x2 + temp1);
fesetenvd (fpenv.d); return (x + x3*temp1);
}
if (absx < 1.0)
{ x2 = cD.d;
x4 = x2*x2;
temp2 = (((((a14*x4+a12)*x4+a10)*x4+a8)*x4+aa6)*x4+aa4)*x4+aa2;
temp1 = (((((a13*x4+a11)*x4+a9)*x4+aa7)*x4+aa5)*x4+aa3)*x4+aa1;
ghead = ((cD.i.hi + 0x3ff00000ul) >> 1) & 0x7ff00000ul;
index = (cD.i.hi >> 13) & 0xfful;
yhead = 0x7fc00000ul - ghead;
temp1 = temp1 + x2*temp2;
gD.i.hi = ghead + ((0xff00ul & SqrtTable[index]) << 4);
gD.i.lo = 0ul;
yD.i.hi = yhead + ((0xfful & SqrtTable[index]) << 12);
yD.i.lo = 0ul;
d = cD.d - gD.d*gD.d;
y = yD.d; g = gD.d + y*d;
y2 = y + y; e = 0.5 - y*g;
d = cD.d - g*g;
y = y + e*y2; g = g + y*d; y2 = y + y;
e = 0.5 - y*g;
d = cD.d - g*g;
y = y + e*y2; g = g + y*d; d = (cD.d - g*g)*y; u = kPiBy2 - 2.0*g; temp1 = aa0 + x2*temp1;
v = (kPiBy2 - u) - 2.0*g; g *= x2;
d = d - 0.5*kPiBy2Tail;
fpenv.i.lo |= FE_INEXACT; temp2 = g*temp1 + (d - 0.5*v);
fesetenvd (fpenv.d); if (x > 0.0)
{ temp2 = -temp2;
return (2.0*temp2 + u);
}
else
return (2.0*temp2 - u);
}
fesetenvd (fpenv.d);
if (absx == 1.0)
{
if (x > 0.0)
return (kPiBy2 + x*kPiBy2Tail);
else
return (-kPiBy2 + x*kPiBy2Tail);
}
fpenv.i.lo |= SET_INVALID;
fesetenvd (fpenv.d);
return ( nan ( INVERSE_TRIGONOMETRIC_NAN ) );
}
#ifdef notdef
float asinf( float x )
{
return (float) asin ( x );
}
#endif
double acos(double x)
{
hexdouble cD, yD, gD, fpenv;
double absx, x2, x3, x4, temp1, temp2, s, u, v, w;
double g, y, d, y2, e;
int index;
unsigned long ghead,yhead;
if (x != x) return ( copysign ( nan ( INVERSE_TRIGONOMETRIC_NAN ), x ) );
absx = __fabs(x);
fegetenvd (fpenv.d); fesetenvd (0.0);
cD.d = 0.5 - 0.5*absx;
x2 = x*x;
if (absx <= 0.5)
{ temp1 = a14*x2 + a13;
x4 = x2*x2;
fpenv.i.lo |= FE_INEXACT; temp1 = temp1*x4 + a11;
temp2 = a12*x4 + a10;
temp1 = temp1*x4 + a9;
temp2 = temp2*x4 + a8;
temp1 = temp1*x4 + a7;
temp2 = temp2*x4 + a6;
temp1 = temp1*x4 + a5;
temp2 = temp2*x4 + a4;
temp1 = temp1*x4 + a3;
temp2 = temp2*x4 + a2;
temp1 = temp1*x4 + a1;
u = kPiBy2 - x; temp1 = temp1 + x2*temp2;
v = kPiBy2 - u - x; x3 = x*x2;
temp1 = a0 + x2*temp1;
w = (v + kPiBy2Tail) - x3*temp1; fesetenvd (fpenv.d); return (u+w);
}
if (absx < 1.0)
{ x2 = cD.d; x4 = x2*x2;
fpenv.i.lo |= FE_INEXACT; temp2 = a14*x4 + a12;
temp1 = a13*x4 + aa11;
temp2 = temp2*x4 + aa10;
temp1 = temp1*x4 + aa9;
temp2 = temp2*x4 + aa8;
temp1 = temp1*x4 + aa7;
temp2 = temp2*x4 + aa6;
temp1 = temp1*x4 + aa5;
temp2 = temp2*x4 + aa4;
temp1 = temp1*x4 + aa3;
temp2 = temp2*x4 + aa2;
temp1 = temp1*x4 + aa1;
ghead = ((cD.i.hi + 0x3ff00000ul) >> 1) & 0x7ff00000ul;
index = (cD.i.hi >> 13) & 0xfful;
yhead = 0x7fc00000ul - ghead;
temp1 = temp1 + x2*temp2; gD.i.hi = ghead + ((0xff00ul & SqrtTable[index]) << 4);
gD.i.lo = 0ul;
yD.i.hi = yhead + ((0xfful & SqrtTable[index]) << 12);
yD.i.lo = 0ul;
d = x2 - gD.d*gD.d;
y = yD.d; g = gD.d + y*d; y2 = y + y;
e = 0.5 - y*g;
d = x2 - g*g;
y = y + e*y2; g = g + y*d; y2 = y + y;
e = 0.5 - y*g;
d = x2 - g*g;
y = y + e*y2; g = g + y*d; d = (x2 - g*g)*y; y2 = g + g;
if (x > 0.0)
{ s = (g*x2)*(aa0 + x2*temp1) + d; fesetenvd (fpenv.d); return (y2 + 2.0*s); } else
{ u = 2.0*kPiBy2 - y2; v = 2.0*kPiBy2 - u - y2; s = (g*x2)*(aa0 + x2*temp1) + ((d - kPiBy2Tail) - 0.5*v); fesetenvd (fpenv.d); s = -s;
return (u + 2.0*s); } }
if (x == 1.0)
{
fesetenvd (fpenv.d); return (0.0);
}
if (x == -1.0)
{
fpenv.i.lo |= FE_INEXACT;
fesetenvd (fpenv.d); return (kPiu.d + 2.0*kPiBy2Tail);
}
fpenv.i.lo |= SET_INVALID;
fesetenvd (fpenv.d);
return ( nan ( INVERSE_TRIGONOMETRIC_NAN ) );
}
#ifdef notdef
float acosf( float x )
{
return (float) acos ( x );
}
#endif
#else
#warning A higher version than gcc-932 is required.
#endif
#endif