#ifdef __APPLE_CC__
#if __APPLE_CC__ > 930
#include "fenv_private.h"
#include "fp_private.h"
extern const unsigned short SqrtTable[];
static const double c13 = 7.6018324085327799e-02;
static const double c11 = -9.0904243427904791e-02;
static const double c9 = 1.1111109821671356e-01;
static const double c7 = -1.4285714283952728e-01;
static const double c5 = 1.9999999999998854e-01;
static const double c3 = -3.3333333333333330e-01;
static const double Rint = 6.755399441055744e15;
static const double PiOver2 = 1.570796326794896619231322;
static const double PiOver2Tail = 6.1232339957367660e-17;
static const hexdouble Pi = HEXDOUBLE(0x400921fb, 0x54442d18);
static const double kMinNormal = 2.2250738585072014e-308;
struct tableEntry
{
double p;
double f5;
double f4;
double f3;
double f2;
double f1;
double f0;
};
extern const unsigned long tanatantable[];
#ifdef notdef
double atan ( double x )
{
hexdouble argument, reducedX, OldEnvironment;
register double fabsOfx, xSquared, xFourth, xThird, temp1, temp2, result, z;
struct tableEntry *tablePointer;
register unsigned long int xHead;
fabsOfx = __FABS ( x );
argument.d = x;
xHead = argument.i.hi & 0x7fffffff;
tablePointer = ( struct tableEntry * ) ( tanatantable - ( 16 * 14 ) );
FEGETENVD( OldEnvironment.d );
if ( xHead > 0x3ff00000)
{
if ( xHead < 0x434d0297UL )
{
register double y, yTail, z, resultHead, resultTail;
y = 1.0 / fabsOfx;
reducedX.d = 256.0 * y + Rint;
xSquared = y * y;
OldEnvironment.i.lo |= FE_INEXACT;
if ( xHead > 0x40300000UL )
{
xFourth = xSquared * xSquared;
xThird = xSquared * y;
temp1 = c9 + xFourth * c13;
temp2 = c7 + xFourth * c11;
temp1 = c5 + xFourth * temp1;
temp2 = c3 + xFourth * temp2;
resultHead = PiOver2 - y;
temp1 = temp2 + xSquared * temp1;
yTail = y * ( 1.0 - fabsOfx * y );
resultTail = ( resultHead - PiOver2 ) + y;
temp1 = PiOver2Tail - xThird * temp1;
if ( x > 0.0 )
result = ( ( ( temp1 - yTail ) - resultTail ) + resultHead );
else
result = ( ( ( yTail - temp1 ) + resultTail ) - resultHead );
FESETENVD( OldEnvironment.d );
return result;
}
yTail = y * ( 1.0 - fabsOfx * y );
z = y - tablePointer[reducedX.i.lo].p + yTail;
resultHead = PiOver2 - tablePointer[reducedX.i.lo].f0;
temp1 = ( ( ( ( tablePointer[reducedX.i.lo].f5 * z
+ tablePointer[reducedX.i.lo].f4 ) * z
+ tablePointer[reducedX.i.lo].f3 ) * z
+ tablePointer[reducedX.i.lo].f2 ) * z
+ tablePointer[reducedX.i.lo].f1 );
if ( x > 0.0 )
result = ( ( PiOver2Tail - z * temp1 ) + resultHead );
else
result = ( ( z * temp1 - PiOver2Tail ) - resultHead );
FESETENVD( OldEnvironment.d );
return result;
}
else
{
if ( x != x )
result = x;
else
{
OldEnvironment.i.lo |= FE_INEXACT;
if ( x > 0.0 )
result = ( Pi.d * 0.5 + PiOver2Tail );
else
result = ( - Pi.d * 0.5 - PiOver2Tail );
}
}
FESETENVD( OldEnvironment.d );
return result;
}
reducedX.d = 256.0 * fabsOfx + Rint;
xSquared = x * x;
if ( xHead > 0x3fb00000UL )
{
z = fabsOfx - tablePointer[reducedX.i.lo].p;
temp1 = ( ( ( ( tablePointer[reducedX.i.lo].f5 * z
+ tablePointer[reducedX.i.lo].f4 ) * z
+ tablePointer[reducedX.i.lo].f3 ) * z
+ tablePointer[reducedX.i.lo].f2 ) * z
+ tablePointer[reducedX.i.lo].f1 );
if ( x > 0.0 )
result = ( tablePointer[reducedX.i.lo].f0 + z * temp1 );
else
result = - z * temp1 - tablePointer[reducedX.i.lo].f0;
OldEnvironment.i.lo |= FE_INEXACT;
FESETENVD( OldEnvironment.d );
return result;
}
if ( fabsOfx == 0.0 )
{
FESETENVD( OldEnvironment.d );
return x;
}
xFourth = xSquared * xSquared;
temp1 = c9 + xFourth * c13;
temp2 = c7 + xFourth * c11;
temp1 = c5 + xFourth * temp1;
temp2 = c3 + xFourth * temp2;
xThird = x * xSquared;
temp1 = temp2 + xSquared * temp1;
result = x + xThird * temp1;
if ( fabs ( result ) < kMinNormal )
OldEnvironment.i.lo |= FE_UNDERFLOW;
OldEnvironment.i.lo |= FE_INEXACT;
FESETENVD( OldEnvironment.d );
return result;
}
#else
static const hexdouble Big = HEXDOUBLE(0x434d0297, 0x00000000);
double atan ( double x )
{
hexdouble reducedX;
register double fabsOfx, xSquared, xFourth, xThird, temp1, temp2, result, y, z;
struct tableEntry *tablePointer;
register double FPR_env, FPR_z, FPR_half, FPR_one, FPR_256, FPR_kMinNormal;
register double FPR_PiDiv2, FPR_PiDiv2Tail, FPR_kRint;
register double FPR_c13, FPR_c11, FPR_c9, FPR_c7, FPR_c5, FPR_c3, FPR_r, FPR_t;
register struct tableEntry *pT;
fabsOfx = __FABS ( x );
if (x != x)
return x;
FPR_z = 0.0; FPR_half = 0.5;
FPR_one = 1.0; FPR_256 = 256.0;
FPR_PiDiv2 = PiOver2; FPR_PiDiv2Tail = PiOver2Tail;
FPR_kRint = Rint; FPR_t = Big.d;
tablePointer = ( struct tableEntry * ) ( tanatantable - ( 16 * 14 ) );
FEGETENVD( FPR_env );
__ENSURE( FPR_z, FPR_kRint, FPR_256 ); __ENSURE( FPR_half, FPR_one, FPR_PiDiv2 );
if ( fabsOfx > FPR_one )
{
__ORI_NOOP;
y = FPR_one / fabsOfx; __ORI_NOOP;
if ( fabsOfx < FPR_t )
{
register double yTail, z, resultHead, resultTail;
xSquared = __FMUL( y, y );
FPR_t = 16.0;
FPR_r = __FMADD( FPR_256, y, FPR_kRint );
__ORI_NOOP;
__ORI_NOOP;
__ORI_NOOP;
reducedX.d = FPR_r;
if ( fabsOfx > FPR_t )
{
xFourth = __FMUL( xSquared, xSquared ); xThird = __FMUL( xSquared, y );
FPR_c13 = c13;
FPR_t = __FNMSUB( fabsOfx, y, FPR_one ); resultHead = FPR_PiDiv2 - y;
FPR_c11 = c11;
FPR_c9 = c9;
yTail = __FMUL( y, FPR_t ); resultTail = ( resultHead - FPR_PiDiv2 ) + y;
FPR_c7 = c7;
temp1 = __FMADD( xFourth, FPR_c13, FPR_c9); temp2 = __FMADD( xFourth, FPR_c11, FPR_c7 );
FPR_c5 = c5; FPR_c3 = c3;
temp1 = __FMADD( xFourth, temp1, FPR_c5 ); temp2 = __FMADD( xFourth, temp2, FPR_c3 );
temp1 = __FMADD( xSquared, temp1, temp2 );
temp1 = __FNMSUB( xThird, temp1, FPR_PiDiv2Tail );
if ( x > FPR_z )
result = ( ( ( temp1 - yTail ) - resultTail ) + resultHead );
else
result = ( ( ( yTail - temp1 ) + resultTail ) - resultHead );
FESETENVD( FPR_env );
__PROG_INEXACT( FPR_PiDiv2 );
return result;
}
pT = &(tablePointer[reducedX.i.lo]); FPR_t = __FNMSUB( fabsOfx, y, FPR_one );
FPR_c13 = pT->p; FPR_c11 = pT->f5;
yTail = __FMUL( y, FPR_t ); z = y - FPR_c13 + yTail;
FPR_c9 = pT->f4; FPR_c7 = pT->f3;
temp1 = __FMADD( FPR_c11, z, FPR_c9 ); __ORI_NOOP;
temp1 = __FMADD( temp1, z, FPR_c7 ); __ORI_NOOP;
FPR_c5 = pT->f2; FPR_c3 = pT->f1;
FPR_t = pT->f0;
temp1 = __FMADD( temp1, z, FPR_c5 );
temp1 = __FMADD( temp1, z, FPR_c3 );
resultHead = FPR_PiDiv2 - FPR_t;
if ( x > FPR_z )
result = ( __FNMSUB( z, temp1, FPR_PiDiv2Tail ) + resultHead );
else
result = ( __FMSUB( z, temp1, FPR_PiDiv2Tail ) - resultHead );
FESETENVD( FPR_env );
__PROG_INEXACT( FPR_PiDiv2 );
return result;
}
else
{
FESETENVD( FPR_env );
FPR_t = Pi.d;
if ( x > FPR_z )
result = __FMADD( FPR_t, FPR_half, FPR_PiDiv2Tail );
else
result = ( - FPR_t * FPR_half - FPR_PiDiv2Tail );
__PROG_INEXACT( FPR_PiDiv2 );
return result;
}
}
FPR_t = .0625;
reducedX.d = __FMADD( FPR_256, fabsOfx, FPR_kRint );
xSquared = __FMUL( x, x );
if ( fabsOfx > FPR_t )
{
pT = &(tablePointer[reducedX.i.lo]); __ORI_NOOP;
FPR_c13 = pT->p; FPR_c11 = pT->f5;
z = fabsOfx - FPR_c13; __ORI_NOOP;
FPR_c9 = pT->f4; FPR_c7 = pT->f3;
temp1 = __FMADD( FPR_c11, z, FPR_c9 ); __ORI_NOOP;
temp1 = __FMADD( temp1, z, FPR_c7 ); __ORI_NOOP;
FPR_c5 = pT->f2; FPR_c3 = pT->f1;
FPR_t = pT->f0;
temp1 = __FMADD( temp1, z, FPR_c5 );
temp1 = __FMADD( temp1, z, FPR_c3 );
if ( x > FPR_z )
result = __FMADD( z, temp1, FPR_t );
else
result = - z * temp1 - FPR_t;
FESETENVD( FPR_env );
__PROG_INEXACT( FPR_PiDiv2 );
return result;
}
if ( fabsOfx == FPR_z )
{
FESETENVD( FPR_env );
return x;
}
xFourth = __FMUL( xSquared, xSquared ); xThird = __FMUL( xSquared, x );
FPR_c13 = c13; FPR_c11 = c11;
FPR_c9 = c9; FPR_c7 = c7;
temp1 = __FMADD( xFourth, FPR_c13, FPR_c9); temp2 = __FMADD( xFourth, FPR_c11, FPR_c7 );
FPR_c5 = c5; FPR_c3 = c3;
temp1 = __FMADD( xFourth, temp1, FPR_c5 ); temp2 = __FMADD( xFourth, temp2, FPR_c3 );
temp1 = __FMADD( xSquared, temp1, temp2 );
FPR_kMinNormal = kMinNormal;
result = __FMADD( xThird, temp1, x );
FESETENVD( FPR_env );
if ( __FABS( result ) >= FPR_kMinNormal )
{
__PROG_INEXACT( FPR_PiDiv2 );
return result;
}
else
{
__PROG_UF_INEXACT( FPR_kMinNormal );
return result;
}
}
double atanCore ( double fabsOfx ) {
hexdouble reducedX;
register double xSquared, xFourth, xThird, temp1, temp2, result, z;
struct tableEntry *tablePointer;
register double FPR_z, FPR_256, FPR_kRint;
register double FPR_c13, FPR_c11, FPR_c9, FPR_c7, FPR_c5, FPR_c3, FPR_r, FPR_s, FPR_t;
register struct tableEntry *pT;
FPR_256 = 256.0; FPR_kRint = Rint;
FPR_r = __FMADD( FPR_256, fabsOfx, FPR_kRint );
reducedX.d = FPR_r;
FPR_s = .0625; FPR_z = 0.0;
tablePointer = ( struct tableEntry * ) ( tanatantable - ( 16 * 14 ) );
xSquared = __FMUL( fabsOfx, fabsOfx ); __ENSURE( FPR_z, FPR_z, FPR_s );
if ( fabsOfx > FPR_s )
{
pT = &(tablePointer[reducedX.i.lo]);
FPR_c13 = pT->p; FPR_c11 = pT->f5;
z = fabsOfx - FPR_c13; __ORI_NOOP;
FPR_c9 = pT->f4; FPR_c7 = pT->f3;
temp1 = __FMADD( FPR_c11, z, FPR_c9 ); __ORI_NOOP;
temp1 = __FMADD( temp1, z, FPR_c7 ); __ORI_NOOP;
FPR_c5 = pT->f2; FPR_c3 = pT->f1;
FPR_t = pT->f0;
temp1 = __FMADD( temp1, z, FPR_c5 );
temp1 = __FMADD( temp1, z, FPR_c3 );
result = __FMADD( z, temp1, FPR_t );
return result;
}
if ( fabsOfx == FPR_z )
return fabsOfx;
xFourth = __FMUL( xSquared, xSquared ); xThird = __FMUL( xSquared, fabsOfx );
FPR_c13 = c13; FPR_c11 = c11;
FPR_c9 = c9; FPR_c7 = c7;
temp1 = __FMADD( xFourth, FPR_c13, FPR_c9); temp2 = __FMADD( xFourth, FPR_c11, FPR_c7 );
FPR_c5 = c5; FPR_c3 = c3;
temp1 = __FMADD( xFourth, temp1, FPR_c5 ); temp2 = __FMADD( xFourth, temp2, FPR_c3 );
temp1 = __FMADD( xSquared, temp1, temp2 );
result = __FMADD( xThird, temp1, fabsOfx );
return result;
}
double atanCoreInv ( double fabsOfx ) {
hexdouble reducedX;
register double xSquared, xFourth, xThird, temp1, temp2, result, y;
struct tableEntry *tablePointer;
register double FPR_z, FPR_half, FPR_one, FPR_256;
register double FPR_PiDiv2, FPR_PiDiv2Tail, FPR_kRint;
register double FPR_c13, FPR_c11, FPR_c9, FPR_c7, FPR_c5, FPR_c3, FPR_r, FPR_s, FPR_t;
register struct tableEntry *pT;
FPR_s = Big.d; y = 1.0 / fabsOfx;
FPR_z = 0.0; FPR_half = 0.5;
FPR_one = 1.0; FPR_256 = 256.0;
FPR_PiDiv2 = PiOver2; FPR_PiDiv2Tail = PiOver2Tail;
__ENSURE( FPR_half, FPR_one, FPR_PiDiv2 ); FPR_kRint = Rint;
__ENSURE( FPR_z, FPR_kRint, FPR_256 );
tablePointer = ( struct tableEntry * ) ( tanatantable - ( 16 * 14 ) );
{
if ( fabsOfx < FPR_s )
{
register double yTail, z, resultHead, resultTail;
FPR_r = __FMADD( FPR_256, y, FPR_kRint );
FPR_s = 16.0;
xSquared = __FMUL( y, y );
__ORI_NOOP;
__ORI_NOOP;
__ORI_NOOP;
reducedX.d = FPR_r;
if ( fabsOfx > FPR_s )
{
xFourth = __FMUL( xSquared, xSquared ); xThird = __FMUL( xSquared, y );
FPR_c13 = c13;
FPR_t = __FNMSUB( fabsOfx, y, FPR_one ); resultHead = FPR_PiDiv2 - y;
FPR_c11 = c11;
FPR_c9 = c9;
yTail = __FMUL( y, FPR_t ); resultTail = ( resultHead - FPR_PiDiv2 ) + y;
FPR_c7 = c7;
temp1 = __FMADD( xFourth, FPR_c13, FPR_c9); temp2 = __FMADD( xFourth, FPR_c11, FPR_c7 );
FPR_c5 = c5; FPR_c3 = c3;
temp1 = __FMADD( xFourth, temp1, FPR_c5 ); temp2 = __FMADD( xFourth, temp2, FPR_c3 );
temp1 = __FMADD( xSquared, temp1, temp2 );
temp1 = __FNMSUB( xThird, temp1, FPR_PiDiv2Tail );
result = ( ( ( temp1 - yTail ) - resultTail ) + resultHead );
return result;
}
pT = &(tablePointer[reducedX.i.lo]); FPR_t = __FNMSUB( fabsOfx, y, FPR_one );
FPR_c13 = pT->p; FPR_c11 = pT->f5;
yTail = __FMUL( y, FPR_t ); z = y - FPR_c13 + yTail;
FPR_c9 = pT->f4; FPR_c7 = pT->f3;
temp1 = __FMADD( FPR_c11, z, FPR_c9 ); __ORI_NOOP;
temp1 = __FMADD( temp1, z, FPR_c7 ); __ORI_NOOP;
FPR_c5 = pT->f2; FPR_c3 = pT->f1;
FPR_t = pT->f0;
temp1 = __FMADD( temp1, z, FPR_c5 );
temp1 = __FMADD( temp1, z, FPR_c3 );
resultHead = FPR_PiDiv2 - FPR_t;
result = ( __FNMSUB( z, temp1, FPR_PiDiv2Tail ) + resultHead );
return result;
}
else
{
if ( fabsOfx != fabsOfx )
result = fabsOfx;
else
{
FPR_t = Pi.d;
result = __FMADD( FPR_t, FPR_half, FPR_PiDiv2Tail );
}
return result;
}
}
}
#endif
#ifdef notdef
float atanf( float x )
{
return (float)atan( x );
}
#endif
#else
#warning A higher version than gcc-932 is required.
#endif
#endif