From 2cc0b4033dd17a9b0b6d12daf26bfb393ddc94f6 Mon Sep 17 00:00:00 2001 From: bde Date: Fri, 7 Apr 1995 23:23:27 +0000 Subject: Submitted by: J.T. Conklin Second part of update to fdlibm 5.2: speed up argument reduction for trig functions in the case pi/4 < |x| < 3pi/4. Remove unused static constants ("one"). --- lib/msun/src/e_log10.c | 3 +-- lib/msun/src/e_log10f.c | 3 +-- lib/msun/src/e_rem_pio2.c | 27 ++++++++++++++++++++++++++- lib/msun/src/e_rem_pio2f.c | 27 ++++++++++++++++++++++++++- lib/msun/src/s_frexp.c | 3 +-- lib/msun/src/s_frexpf.c | 3 +-- 6 files changed, 56 insertions(+), 10 deletions(-) (limited to 'lib/msun') diff --git a/lib/msun/src/e_log10.c b/lib/msun/src/e_log10.c index 3e27b1c..69a2356 100644 --- a/lib/msun/src/e_log10.c +++ b/lib/msun/src/e_log10.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: e_log10.c,v 1.6 1994/08/18 23:05:44 jtc Exp $"; +static char rcsid[] = "$Id: e_log10.c,v 1.1.1.1 1994/08/19 09:39:44 jkh Exp $"; #endif /* __ieee754_log10(x) @@ -55,7 +55,6 @@ static const double #else static double #endif -one = 1.0, two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */ ivln10 = 4.34294481903251816668e-01, /* 0x3FDBCB7B, 0x1526E50E */ log10_2hi = 3.01029995663611771306e-01, /* 0x3FD34413, 0x509F6000 */ diff --git a/lib/msun/src/e_log10f.c b/lib/msun/src/e_log10f.c index 9ac22b5..d493ad8 100644 --- a/lib/msun/src/e_log10f.c +++ b/lib/msun/src/e_log10f.c @@ -14,7 +14,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: e_log10f.c,v 1.2 1994/08/18 23:05:46 jtc Exp $"; +static char rcsid[] = "$Id: e_log10f.c,v 1.1.1.1 1994/08/19 09:39:56 jkh Exp $"; #endif #include "math.h" @@ -25,7 +25,6 @@ static const float #else static float #endif -one = 1.0, two25 = 3.3554432000e+07, /* 0x4c000000 */ ivln10 = 4.3429449201e-01, /* 0x3ede5bd9 */ log10_2hi = 3.0102920532e-01, /* 0x3e9a2080 */ diff --git a/lib/msun/src/e_rem_pio2.c b/lib/msun/src/e_rem_pio2.c index bf8bfe1..be7cd50 100644 --- a/lib/msun/src/e_rem_pio2.c +++ b/lib/msun/src/e_rem_pio2.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: e_rem_pio2.c,v 1.5 1994/08/18 23:05:56 jtc Exp $"; +static char rcsid[] = "$Id: e_rem_pio2.c,v 1.1.1.1 1994/08/19 09:39:44 jkh Exp $"; #endif /* __ieee754_rem_pio2(x,y) @@ -99,6 +99,31 @@ pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */ ix = hx&0x7fffffff; if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */ {y[0] = x; y[1] = 0; return 0;} + if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */ + if(hx>0) { + z = x - pio2_1; + if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ + y[0] = z - pio2_1t; + y[1] = (z-y[0])-pio2_1t; + } else { /* near pi/2, use 33+33+53 bit pi */ + z -= pio2_2; + y[0] = z - pio2_2t; + y[1] = (z-y[0])-pio2_2t; + } + return 1; + } else { /* negative x */ + z = x + pio2_1; + if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */ + y[0] = z + pio2_1t; + y[1] = (z-y[0])+pio2_1t; + } else { /* near pi/2, use 33+33+53 bit pi */ + z += pio2_2; + y[0] = z + pio2_2t; + y[1] = (z-y[0])+pio2_2t; + } + return -1; + } + } if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */ t = fabs(x); n = (int32_t) (t*invpio2+half); diff --git a/lib/msun/src/e_rem_pio2f.c b/lib/msun/src/e_rem_pio2f.c index eae6473..153a8c4 100644 --- a/lib/msun/src/e_rem_pio2f.c +++ b/lib/msun/src/e_rem_pio2f.c @@ -14,7 +14,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: e_rem_pio2f.c,v 1.2 1994/08/18 23:05:58 jtc Exp $"; +static char rcsid[] = "$Id: e_rem_pio2f.c,v 1.1.1.1 1994/08/19 09:39:57 jkh Exp $"; #endif /* __ieee754_rem_pio2f(x,y) @@ -114,6 +114,31 @@ pio2_3t = 6.1232342629e-17; /* 0x248d3132 */ ix = hx&0x7fffffff; if(ix<=0x3f490fd8) /* |x| ~<= pi/4 , no need for reduction */ {y[0] = x; y[1] = 0; return 0;} + if(ix<0x4016cbe4) { /* |x| < 3pi/4, special case with n=+-1 */ + if(hx>0) { + z = x - pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z - pio2_1t; + y[1] = (z-y[0])-pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z -= pio2_2; + y[0] = z - pio2_2t; + y[1] = (z-y[0])-pio2_2t; + } + return 1; + } else { /* negative x */ + z = x + pio2_1; + if((ix&0xfffffff0)!=0x3fc90fd0) { /* 24+24 bit pi OK */ + y[0] = z + pio2_1t; + y[1] = (z-y[0])+pio2_1t; + } else { /* near pi/2, use 24+24+24 bit pi */ + z += pio2_2; + y[0] = z + pio2_2t; + y[1] = (z-y[0])+pio2_2t; + } + return -1; + } + } if(ix<=0x43490f80) { /* |x| ~<= 2^7*(pi/2), medium size */ t = fabsf(x); n = (int32_t) (t*invpio2+half); diff --git a/lib/msun/src/s_frexp.c b/lib/msun/src/s_frexp.c index 6bbec50..00d344f 100644 --- a/lib/msun/src/s_frexp.c +++ b/lib/msun/src/s_frexp.c @@ -11,7 +11,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: s_frexp.c,v 1.6 1994/08/18 23:06:49 jtc Exp $"; +static char rcsid[] = "$Id: s_frexp.c,v 1.1.1.1 1994/08/19 09:39:51 jkh Exp $"; #endif /* @@ -32,7 +32,6 @@ static const double #else static double #endif -one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ two54 = 1.80143985094819840000e+16; /* 0x43500000, 0x00000000 */ #ifdef __STDC__ diff --git a/lib/msun/src/s_frexpf.c b/lib/msun/src/s_frexpf.c index 6e341fd..6988cbe 100644 --- a/lib/msun/src/s_frexpf.c +++ b/lib/msun/src/s_frexpf.c @@ -14,7 +14,7 @@ */ #ifndef lint -static char rcsid[] = "$Id: s_frexpf.c,v 1.2 1994/08/18 23:06:51 jtc Exp $"; +static char rcsid[] = "$Id: s_frexpf.c,v 1.1.1.1 1994/08/19 09:39:58 jkh Exp $"; #endif #include "math.h" @@ -25,7 +25,6 @@ static const float #else static float #endif -one = 1.0000000000e+00, /* 0x3F800000 */ two25 = 3.3554432000e+07; /* 0x4c000000 */ #ifdef __STDC__ -- cgit v1.1