Use __ieee754_sqrt() instead of sqrt() internally. Similarly for the

float versions.  Using sqrt() was inefficient.

Obtained from:	NetBSD
This commit is contained in:
Bruce Evans 1997-03-09 16:29:29 +00:00
parent efda6cd9d5
commit 9faa8dc6cc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=23579
12 changed files with 33 additions and 33 deletions

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_acos.c,v 1.5 1997/02/22 15:09:54 peter Exp $";
#endif
/* __ieee754_acos(x)
@ -35,7 +35,7 @@ static char rcsid[] = "$Id$";
* if x is NaN, return x itself;
* if |x|>1, return NaN with invalid signal.
*
* Function needed: sqrt
* Function needed: __ieee754_sqrt
*/
#include "math.h"
@ -92,13 +92,13 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
z = (one+x)*0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
s = sqrt(z);
s = __ieee754_sqrt(z);
r = p/q;
w = r*s-pio2_lo;
return pi - 2.0*(s+w);
} else { /* x > 0.5 */
z = (one-x)*0.5;
s = sqrt(z);
s = __ieee754_sqrt(z);
df = s;
SET_LOW_WORD(df,0);
c = (z-df*df)/(s+df);

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_acosf.c,v 1.4 1997/02/22 15:09:55 peter Exp $";
#endif
#include "math.h"
@ -68,14 +68,14 @@ qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5)))));
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4)));
s = sqrtf(z);
s = __ieee754_sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
return pi - (float)2.0*(s+w);
} else { /* x > 0.5 */
int32_t idf;
z = (one-x)*(float)0.5;
s = sqrtf(z);
s = __ieee754_sqrtf(z);
df = s;
GET_FLOAT_WORD(idf,df);
SET_FLOAT_WORD(df,idf&0xfffff000);

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_acosh.c,v 1.4 1997/02/22 15:09:56 peter Exp $";
#endif
/* __ieee754_acosh(x)
@ -61,9 +61,9 @@ ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */
return 0.0; /* acosh(1) = 0 */
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */
t=x*x;
return __ieee754_log(2.0*x-one/(x+sqrt(t-one)));
return __ieee754_log(2.0*x-one/(x+__ieee754_sqrt(t-one)));
} else { /* 1<x<2 */
t = x-one;
return log1p(t+sqrt(2.0*t+t*t));
return log1p(t+__ieee754_sqrt(2.0*t+t*t));
}
}

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_acoshf.c,v 1.4 1997/02/22 15:09:56 peter Exp $";
#endif
#include "math.h"
@ -49,9 +49,9 @@ ln2 = 6.9314718246e-01; /* 0x3f317218 */
return 0.0; /* acosh(1) = 0 */
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */
t=x*x;
return __ieee754_logf((float)2.0*x-one/(x+sqrtf(t-one)));
return __ieee754_logf((float)2.0*x-one/(x+__ieee754_sqrtf(t-one)));
} else { /* 1<x<2 */
t = x-one;
return log1pf(t+sqrtf((float)2.0*t+t*t));
return log1pf(t+__ieee754_sqrtf((float)2.0*t+t*t));
}
}

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_asin.c,v 1.6 1997/02/22 15:09:57 peter Exp $";
#endif
/* __ieee754_asin(x)
@ -103,7 +103,7 @@ qS4 = 7.70381505559019352791e-02; /* 0x3FB3B8C5, 0xB12E9282 */
t = w*0.5;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
s = sqrt(t);
s = __ieee754_sqrt(t);
if(ix>=0x3FEF3333) { /* if |x| > 0.975 */
w = p/q;
t = pio2_hi-(2.0*(s+s*w)-pio2_lo);

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_asinf.c,v 1.5 1997/02/22 15:09:58 peter Exp $";
#endif
#include "math.h"
@ -73,7 +73,7 @@ qS4 = 7.7038154006e-02; /* 0x3d9dc62e */
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5)))));
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4)));
s = sqrtf(t);
s = __ieee754_sqrtf(t);
if(ix>=0x3F79999A) { /* if |x| > 0.975 */
w = p/q;
t = pio2_hi-((float)2.0*(s+s*w)-pio2_lo);

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_hypot.c,v 1.4 1997/02/22 15:10:12 peter Exp $";
#endif
/* __ieee754_hypot(x,y)
@ -107,7 +107,7 @@ static char rcsid[] = "$Id$";
t1 = 0;
SET_HIGH_WORD(t1,ha);
t2 = a-t1;
w = sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
w = __ieee754_sqrt(t1*t1-(b*(-b)-t2*(a+t1)));
} else {
a = a+a;
y1 = 0;
@ -116,7 +116,7 @@ static char rcsid[] = "$Id$";
t1 = 0;
SET_HIGH_WORD(t1,ha+0x00100000);
t2 = a - t1;
w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
w = __ieee754_sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b)));
}
if(k!=0) {
u_int32_t high;

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id: e_hypotf.c,v 1.4 1997/02/22 15:10:13 peter Exp $";
static char rcsid[] = "$Id: e_hypotf.c,v 1.5 1997/03/05 11:54:00 bde Exp $";
#endif
#include "math.h"
@ -71,14 +71,14 @@ static char rcsid[] = "$Id: e_hypotf.c,v 1.4 1997/02/22 15:10:13 peter Exp $";
if (w>b) {
SET_FLOAT_WORD(t1,ha&0xfffff000);
t2 = a-t1;
w = sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
w = __ieee754_sqrtf(t1*t1-(b*(-b)-t2*(a+t1)));
} else {
a = a+a;
SET_FLOAT_WORD(y1,hb&0xfffff000);
y2 = b - y1;
SET_FLOAT_WORD(t1,ha+0x00800000);
t2 = a - t1;
w = sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
w = __ieee754_sqrtf(t1*y1-(w*(-w)-(t1*y2+t2*b)));
}
if(k!=0) {
SET_FLOAT_WORD(t1,0x3f800000+(k<<23));

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_pow.c,v 1.4 1997/02/22 15:10:29 peter Exp $";
#endif
/* __ieee754_pow(x,y) return x**y
@ -160,7 +160,7 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3fe00000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
return sqrt(x);
return __ieee754_sqrt(x);
}
}

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: e_powf.c,v 1.4 1997/02/22 15:10:30 peter Exp $";
#endif
#include "math.h"
@ -111,7 +111,7 @@ ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
if(hy==0x40000000) return x*x; /* y is 2 */
if(hy==0x3f000000) { /* y is 0.5 */
if(hx>=0) /* x >= +0 */
return sqrtf(x);
return __ieee754_sqrtf(x);
}
ax = fabsf(x);

View File

@ -11,7 +11,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: s_asinh.c,v 1.4 1997/02/22 15:10:56 peter Exp $";
#endif
/* asinh(x)
@ -56,10 +56,10 @@ huge= 1.00000000000000000000e+300;
w = __ieee754_log(fabs(x))+ln2;
} else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
t = fabs(x);
w = __ieee754_log(2.0*t+one/(sqrt(x*x+one)+t));
w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t));
} else { /* 2.0 > |x| > 2**-28 */
t = x*x;
w =log1p(fabs(x)+t/(one+sqrt(one+t)));
w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t)));
}
if(hx>0) return w; else return -w;
}

View File

@ -14,7 +14,7 @@
*/
#ifndef lint
static char rcsid[] = "$Id$";
static char rcsid[] = "$Id: s_asinhf.c,v 1.4 1997/02/22 15:10:57 peter Exp $";
#endif
#include "math.h"
@ -48,10 +48,10 @@ huge= 1.0000000000e+30;
w = __ieee754_logf(fabsf(x))+ln2;
} else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */
t = fabsf(x);
w = __ieee754_logf((float)2.0*t+one/(sqrtf(x*x+one)+t));
w = __ieee754_logf((float)2.0*t+one/(__ieee754_sqrtf(x*x+one)+t));
} else { /* 2.0 > |x| > 2**-28 */
t = x*x;
w =log1pf(fabsf(x)+t/(one+sqrtf(one+t)));
w =log1pf(fabsf(x)+t/(one+__ieee754_sqrtf(one+t)));
}
if(hx>0) return w; else return -w;
}