#ifdef __APPLE_CC__
#if __APPLE_CC__ > 930
#include "fenv_private.h"
#include "fp_private.h"
#define TRIG_NAN "33"
static const double kPiScale42 = 1.38168706094305449e13; static const double kPiScale53 = 2.829695100811376e16; static const double piOver4 = 0.785398163397448390; static const double piOver2 = 1.570796326794896619231322; static const double piOver2Tail = 6.1232339957367660e-17; static const double twoOverPi = 0.636619772367581382; static const double kMinNormal = 2.2250738585072014e-308; static const double kRintBig = 2.7021597764222976e16; static const double kRint = 6.755399441055744e15; static const hexdouble infinity = HEXDOUBLE(0x7ff00000, 0x00000000);
static const double s13 = 1.5868926979889205164e-10; static const double s11 = -2.5050225177523807003e-8; static const double s9 = 2.7557309793219876880e-6; static const double s7 = -1.9841269816180999116e-4; static const double s5 = 8.3333333332992771264e-3; static const double s3 = -0.16666666666666463126; static const double c14 = -1.138218794258068723867e-11; static const double c12 = 2.087614008917893178252e-9; static const double c10 = -2.755731724204127572108e-7; static const double c8 = 2.480158729870839541888e-5; static const double c6 = -1.388888888888735934799e-3; static const double c4 = 4.166666666666666534980e-2; static const double c2 = -.5;
#ifdef notdef
double sin ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth, temp1, temp2, result;
register unsigned long int ltable;
hexdouble z, OldEnvironment;
absOfX = __FABS ( x );
FEGETENVD( OldEnvironment.d ); FESETENVD( 0.0 );
if ( absOfX < piOver4 )
{
if ( absOfX == 0.0 )
{
FESETENVD( OldEnvironment.d ); return x; }
xSquared = x * x; xFourth = xSquared * xSquared;
OldEnvironment.i.lo |= FE_INEXACT;
temp1 = s9 + s13*xFourth;
temp2 = s7 + s11*xFourth;
temp1 = s5 + temp1*xFourth;
temp2 = s3 + temp2*xFourth;
xThird = xSquared * x;
temp1 = temp2 + xSquared * temp1;
result = x + xThird * temp1;
if ( fabs ( result ) < kMinNormal )
OldEnvironment.i.lo |= FE_UNDERFLOW;
FESETENVD( OldEnvironment.d ); return ( result ) ;
}
if ( x != x ) {
FESETENVD( OldEnvironment.d ); return ( x );
}
if ( absOfX > kPiScale42 )
{
if ( absOfX == infinity.d )
{ OldEnvironment.i.lo |= SET_INVALID;
FESETENVD( OldEnvironment.d ); return ( nan ( TRIG_NAN ) ); }
while ( absOfX > kPiScale53 )
{ intquo = x * twoOverPi; x = ( x - intquo * piOver2 ) - intquo * piOver2Tail;
absOfX = __FABS ( x ) ;
}
intquo = ( x * twoOverPi + kRintBig) - kRintBig;
x = ( x - intquo * piOver2) - intquo * piOver2Tail;
absOfX = __FABS( x );
}
z.d = x * twoOverPi + kRint; intquo = z.d - kRint;
arg = ( x - intquo * piOver2 ) - intquo * piOver2Tail;
OldEnvironment.i.lo |= FE_INEXACT; xSquared = arg * arg;
argtail = ( ( x - intquo * piOver2 ) - arg ) - intquo * piOver2Tail;
xFourth = xSquared * xSquared;
ltable = z.i.lo & FE_ALL_RND;
if ( ltable & 0x1ul )
{
temp1 = c10 + c14 * xFourth;
temp2 = c8 + c12 * xFourth;
temp1 = c6 + temp1 * xFourth;
temp2 = c4 + temp2 * xFourth;
temp1 = c2 + temp1 * xFourth;
temp1 = temp1 + xSquared * temp2;
temp1 = arg*temp1 - argtail; if ( ltable < 2 ) result = 1.0 + arg * temp1; else
{
arg = - arg;
result = arg * temp1 - 1.0; }
}
else
{
temp1 = s9 + s13 * xFourth;
temp2 = s7 + s11 * xFourth;
temp1 = s5 + temp1 * xFourth;
temp2 = s3 + temp2 * xFourth;
xThird = xSquared * arg;
temp1 = temp2 + xSquared * temp1;
temp1 = temp1 * xThird + argtail; if ( ltable < 2 ) result = arg + temp1 ; else
{
arg = - arg;
result = arg - temp1; }
}
FESETENVD( OldEnvironment.d ); return ( result ) ;
}
#else
double sin ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth, temp1, temp2, result;
register unsigned long int ltable;
hexdouble z, OldEnvironment;
register double FPR_env, FPR_z, FPR_Min, FPR_pi4, FPR_piScale;
register double FPR_t, FPR_inf, FPR_pi53, FPR_2divPi, FPR_PiDiv2, FPR_PiDiv2Tail, FPR_kRintBig, FPR_kRint;
register unsigned long GPR_f;
FEGETENVD( FPR_env ); FPR_z = 0.0;
FPR_pi4 = piOver4;
absOfX = __FABS ( x ); __ENSURE( FPR_z, FPR_z, FPR_pi4 );
FESETENVD( FPR_z );
if ( absOfX < FPR_pi4 ) {
if ( absOfX != FPR_z )
{
register double FPR_s3, FPR_s5, FPR_s7, FPR_s9, FPR_s11, FPR_s13;
xSquared = __FMUL( x, x );
FPR_Min = kMinNormal;
__ENSURE( FPR_z, FPR_z, FPR_Min );
FPR_s9 = s9; FPR_s13 = s13;
FPR_s7 = s7; FPR_s11 = s11;
xFourth = __FMUL( xSquared, xSquared ); xThird = __FMUL( x, xSquared );
FPR_s5 = s5;
FPR_s3 = s3;
temp1 = __FMADD( s13, xFourth, s9 ); temp2 = __FMADD( s11, xFourth, s7 );
temp1 = __FMADD( temp1, xFourth, s5 ); temp2 = __FMADD( temp2, xFourth, s3 );
temp1 = __FMADD( temp1, xSquared, temp2 ); result = __FMADD( temp1, xThird, x );
FESETENVD( FPR_env );
if ( __FABS( result ) < FPR_Min )
__PROG_UF_INEXACT( FPR_Min );
else
__PROG_INEXACT( FPR_pi4 );
return ( result );
}
else
{
FESETENVD( FPR_env ); return x; }
}
if ( x != x ) {
FESETENVD( FPR_env ); return ( x );
}
FPR_piScale = kPiScale42;
FPR_piScale = __FMADD( FPR_z, FPR_z, FPR_piScale );
FPR_inf = infinity.d; FPR_pi53 = kPiScale53;
FPR_2divPi = twoOverPi; FPR_PiDiv2 = piOver2;
FPR_PiDiv2Tail = piOver2Tail; FPR_kRintBig = kRintBig;
FPR_kRint = kRint;
if ( absOfX > FPR_piScale )
{
if ( absOfX == FPR_inf )
{ OldEnvironment.d = FPR_env;
OldEnvironment.i.lo |= SET_INVALID;
FESETENVD( OldEnvironment.d ); return ( nan ( TRIG_NAN ) ); }
while ( absOfX > FPR_pi53 )
{ intquo = __FMUL( x, FPR_2divPi ); FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x );
x = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
absOfX = __FABS ( x ) ;
}
FPR_t = __FMADD( x, FPR_2divPi, FPR_kRintBig );
intquo = FPR_t - FPR_kRintBig;
FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x );
x = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
absOfX = __FABS( x );
}
FPR_t = __FMADD( x, FPR_2divPi, FPR_kRint ); intquo = FPR_t - FPR_kRint;
z.d = FPR_t;
FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x ); arg = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
xSquared = __FMUL( arg, arg ); FPR_t -= arg;
GPR_f = z.i.lo;
xFourth = __FMUL( xSquared, xSquared ); argtail = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
ltable = GPR_f & FE_ALL_RND;
if ( ltable & 0x1ul )
{
register double FPR_c2, FPR_c4, FPR_c6, FPR_c8, FPR_c10, FPR_c12, FPR_c14;
FPR_c10 = c10; FPR_c14 = c14;
FPR_c8 = c8; FPR_c12 = c12;
temp1 = __FMADD( FPR_c14, xFourth, FPR_c10 ); temp2 = __FMADD( FPR_c12, xFourth, FPR_c8);
FPR_c6 = c6;
FPR_c4 = c4;
temp1 = __FMADD( temp1, xFourth, FPR_c6 ); temp2 = __FMADD( temp2, xFourth, FPR_c4);
FPR_c2 = c2;
temp1 = __FMADD( temp1, xFourth, FPR_c2 );
temp1 = __FMADD( xSquared, temp2, temp1 );
temp1 = __FMSUB( arg, temp1, argtail );
if ( ltable < 2 ) result = __FMADD( arg, temp1, 1.0 ); else
{
arg = - arg;
result =__FMSUB( arg, temp1, 1.0 ); }
FESETENVD( FPR_env ); __PROG_INEXACT( FPR_PiDiv2 );
}
else
{
register double FPR_s3, FPR_s5, FPR_s7, FPR_s9, FPR_s11, FPR_s13;
FPR_s9 = s9; FPR_s13 = s13;
FPR_s7 = s7; FPR_s11 = s11;
temp1 = __FMADD( FPR_s13, xFourth, FPR_s9 );temp2 = __FMADD( FPR_s11, xFourth, FPR_s7 );
FPR_s5 = s5;
FPR_s3 = s3;
temp1 = __FMADD( temp1, xFourth, FPR_s5 ); temp2 = __FMADD( temp2, xFourth, FPR_s3 );
temp1 = __FMADD( temp1, xSquared, temp2 ); xThird = __FMUL( arg, xSquared );
temp1 = __FMADD( temp1, xThird, argtail );
if ( ltable < 2 ) result = arg + temp1 ; else
{
arg = - arg;
result = arg - temp1; }
FESETENVD( FPR_env ); __PROG_INEXACT( FPR_PiDiv2 );
}
return ( result ) ;
}
#endif
#ifdef notdef
double cos ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth,
temp1, temp2, result;
register unsigned long int iquad;
hexdouble z, OldEnvironment;
absOfX = __FABS( x );
FEGETENVD( OldEnvironment.d ); FESETENVD( 0.0 );
if ( absOfX < piOver4 )
{ if ( absOfX == 0.0 )
{
FESETENVD( OldEnvironment.d ); return 1.0;
}
xSquared = x * x; xFourth = xSquared * xSquared;
temp1 = c10 + c14 * xFourth;
temp2 = c8 + c12 * xFourth;
temp1 = c6 + temp1 * xFourth;
temp2 = c4 + temp2 * xFourth;
temp1 = c2 + temp1 * xFourth;
OldEnvironment.i.lo |= FE_INEXACT;
temp2 = temp1 + xSquared * temp2;
result = 1.0 + xSquared * temp2;
FESETENVD( OldEnvironment.d ); return ( result );
}
if ( x != x ) {
FESETENVD( OldEnvironment.d ); return ( x );
}
if ( absOfX > kPiScale42 )
{
if ( absOfX == infinity.d )
{ OldEnvironment.i.lo |= SET_INVALID;
FESETENVD( OldEnvironment.d ); return ( nan ( TRIG_NAN ) ); }
while ( absOfX > kPiScale53 )
{ intquo = x * twoOverPi; x = ( x - intquo * piOver2) - intquo * piOver2Tail;
absOfX = __FABS( x );
}
intquo = ( x * twoOverPi + kRintBig) - kRintBig;
x = ( x - intquo * piOver2) - intquo * piOver2Tail;
absOfX = __FABS ( x );
}
z.d = x*twoOverPi + kRint; OldEnvironment.i.lo |= FE_INEXACT; iquad = ( z.i.lo + 1 ) & FE_ALL_RND; intquo = z.d - kRint;
arg = ( x - intquo * piOver2 ) - intquo * piOver2Tail;
xSquared = arg*arg;
argtail = ( ( x - intquo * piOver2) - arg) - intquo * piOver2Tail;
xFourth = xSquared * xSquared;
if ( iquad & 0x1UL)
{
temp1 = c10 + c14 * xFourth;
temp2 = c8 + c12 * xFourth;
temp1 = c6 + temp1 * xFourth;
temp2 = c4 + temp2 * xFourth;
temp1 = c2 + temp1 * xFourth;
temp1 = temp1 + xSquared * temp2;
temp1 = arg * temp1 - argtail; if ( iquad < 2 ) result = 1.0 + arg * temp1;
else
{
arg = - arg;
result = arg * temp1 - 1.0;
}
}
else
{
temp1 = s9 + s13 * xFourth;
temp2 = s7 + s11 * xFourth;
temp1 = s5 + temp1 * xFourth;
temp2 = s3 + temp2 * xFourth;
xThird = xSquared * arg;
temp1 = temp2 + xSquared * temp1;
temp1 = temp1 * xThird + argtail; if ( iquad < 2 ) result = temp1 + arg;
else
{
arg = - arg;
result = arg - temp1;
}
}
FESETENVD( OldEnvironment.d ); return ( result ) ;
}
#else
double cos ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth,
temp1, temp2, result;
register unsigned long int iquad;
hexdouble z, OldEnvironment;
register double FPR_env, FPR_z, FPR_pi4, FPR_piScale;
register double FPR_t, FPR_inf, FPR_pi53, FPR_2divPi, FPR_PiDiv2, FPR_PiDiv2Tail, FPR_kRintBig, FPR_kRint;
register unsigned long GPR_f;
FEGETENVD( FPR_env ); FPR_z = 0.0;
FPR_pi4 = piOver4;
absOfX = __FABS ( x ); __ENSURE( FPR_z, FPR_z, FPR_pi4 );
FESETENVD( FPR_z );
if ( absOfX < FPR_pi4 ) {
if ( absOfX != FPR_z )
{
register double FPR_c2, FPR_c4, FPR_c6, FPR_c8, FPR_c10, FPR_c12, FPR_c14, FPR_One;
xSquared = __FMUL( x, x );
FPR_One = 1.0;
__ENSURE( FPR_z, FPR_z, FPR_One );
FPR_c10 = c10; FPR_c14 = c14;
FPR_c8 = c8; FPR_c12 = c12;
FPR_c6 = c6; FPR_c4 = c4;
xFourth = __FMUL( xSquared, xSquared );
__ORI_NOOP;
FPR_c2 = c2;
temp1 = __FMADD( FPR_c14, xFourth, FPR_c10 ); temp2 = __FMADD( FPR_c12, xFourth, FPR_c8);
temp1 = __FMADD( temp1, xFourth, FPR_c6 ); temp2 = __FMADD( temp2, xFourth, FPR_c4);
temp1 = __FMADD( temp1, xFourth, FPR_c2 ); temp1 = __FMADD( xSquared, temp2, temp1 );
result = __FMADD( xSquared, temp1, FPR_One );
FESETENVD( FPR_env ); __PROG_INEXACT( FPR_pi4 );
return ( result );
}
else
{
FESETENVD( FPR_env ); return 1.0;
}
}
if ( x != x ) {
FESETENVD( FPR_env ); return ( x );
}
FPR_piScale = kPiScale42;
FPR_piScale = __FMADD( FPR_z, FPR_z, FPR_piScale );
FPR_inf = infinity.d; FPR_pi53 = kPiScale53;
FPR_2divPi = twoOverPi; FPR_PiDiv2 = piOver2;
FPR_PiDiv2Tail = piOver2Tail; FPR_kRintBig = kRintBig;
FPR_kRint = kRint;
if ( absOfX > FPR_piScale )
{
if ( absOfX == infinity.d )
{ OldEnvironment.d = FPR_env;
OldEnvironment.i.lo |= SET_INVALID;
FESETENVD( OldEnvironment.d ); return ( nan ( TRIG_NAN ) ); }
while ( absOfX > FPR_pi53 )
{ intquo = __FMUL( x, FPR_2divPi ); FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x );
x = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
absOfX = __FABS ( x ) ;
}
FPR_t = __FMADD( x, FPR_2divPi, FPR_kRintBig );
intquo = FPR_t - FPR_kRintBig;
FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x );
x = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
absOfX = __FABS( x );
}
FPR_t = __FMADD( x, FPR_2divPi, FPR_kRint );
intquo = FPR_t - FPR_kRint;
z.d = FPR_t;
FPR_t = __FNMSUB( intquo, FPR_PiDiv2, x );
arg = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
xSquared = __FMUL( arg, arg ); FPR_t -= arg;
GPR_f = z.i.lo;
xFourth = __FMUL( xSquared, xSquared ); argtail = __FNMSUB( intquo, FPR_PiDiv2Tail, FPR_t );
iquad = (GPR_f + 1 ) & FE_ALL_RND;
if ( iquad & 0x1UL)
{
register double FPR_c2, FPR_c4, FPR_c6, FPR_c8, FPR_c10, FPR_c12, FPR_c14;
FPR_c10 = c10; FPR_c14 = c14;
FPR_c8 = c8; FPR_c12 = c12;
temp1 = __FMADD( FPR_c14, xFourth, FPR_c10 ); temp2 = __FMADD( FPR_c12, xFourth, FPR_c8);
FPR_c6 = c6;
FPR_c4 = c4;
temp1 = __FMADD( temp1, xFourth, FPR_c6 ); temp2 = __FMADD( temp2, xFourth, FPR_c4);
FPR_c2 = c2;
temp1 = __FMADD( temp1, xFourth, FPR_c2 ); temp1 = __FMADD( xSquared, temp2, temp1 );
temp1 = __FMSUB( arg, temp1, argtail ); if ( iquad < 2 ) result = __FMADD( arg, temp1, 1.0 ); else
{
arg = - arg;
result =__FMSUB( arg, temp1, 1.0 ); }
}
else
{
register double FPR_s3, FPR_s5, FPR_s7, FPR_s9, FPR_s11, FPR_s13;
FPR_s9 = s9; FPR_s13 = s13;
FPR_s7 = s7; FPR_s11 = s11;
temp1 = __FMADD( FPR_s13, xFourth, FPR_s9 ); temp2 = __FMADD( FPR_s11, xFourth, FPR_s7 );
FPR_s5 = s5;
FPR_s3 = s3;
temp1 = __FMADD( temp1, xFourth, FPR_s5 ); temp2 = __FMADD( temp2, xFourth, FPR_s3 );
temp1 = __FMADD( temp1, xSquared, temp2 ); xThird = __FMUL( arg, xSquared );
temp1 = __FMADD( temp1, xThird, argtail );
if ( iquad < 2 ) result = temp1 + arg;
else
{
arg = - arg;
result = arg - temp1;
}
}
FESETENVD( FPR_env ); __PROG_INEXACT( FPR_PiDiv2 );
return ( result ) ;
}
#endif
#else
#warning A higher version than gcc-932 is required.
#endif
#endif