#include "fenv_private.h"
#include "fp_private.h"
#include "math.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 = 0x1.0p-1022; 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;
double sin ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth, temp1, temp2, result;
register uint32_t 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 uint32_t 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 (likely( 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 (unlikely( __FABS( result ) < FPR_Min ))
__PROG_UF_INEXACT( FPR_Min );
else
__PROG_INEXACT( FPR_pi4 );
return ( result );
}
else
{
FESETENVD( FPR_env ); return x; }
}
if (unlikely( 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 (unlikely( absOfX > FPR_piScale ))
{
if ( absOfX == FPR_inf )
{ OldEnvironment.d = FPR_env;
__NOOP;
__NOOP;
__NOOP;
OldEnvironment.i.lo |= SET_INVALID;
FESETENVD_GRP( 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 & 0x1u )
{
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 ) ;
}
double cos ( double x )
{
register double absOfX, intquo, arg, argtail, xSquared, xThird, xFourth,
temp1, temp2, result;
register uint32_t 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 uint32_t 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 (likely( 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 );
__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 (unlikely( 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 (unlikely( absOfX > FPR_piScale ))
{
if ( absOfX == infinity.d )
{ OldEnvironment.d = FPR_env;
__NOOP;
__NOOP;
__NOOP;
OldEnvironment.i.lo |= SET_INVALID;
FESETENVD_GRP( 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 & 0x1u)
{
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 ) ;
}