| 1 |
diff --git a/e_acos.cpp b/e_acos.cpp |
| 2 |
--- a/e_acos.cpp |
| 3 |
+++ b/e_acos.cpp |
| 4 |
@@ -33,16 +33,17 @@ |
| 5 |
* |
| 6 |
* Special cases: |
| 7 |
* if x is NaN, return x itself; |
| 8 |
* if |x|>1, return NaN with invalid signal. |
| 9 |
* |
| 10 |
* Function needed: sqrt |
| 11 |
*/ |
| 12 |
|
| 13 |
+#include <cmath> |
| 14 |
#include <float.h> |
| 15 |
|
| 16 |
#include "math_private.h" |
| 17 |
|
| 18 |
static const double |
| 19 |
one= 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
| 20 |
pi = 3.14159265358979311600e+00, /* 0x400921FB, 0x54442D18 */ |
| 21 |
pio2_hi = 1.57079632679489655800e+00; /* 0x3FF921FB, 0x54442D18 */ |
| 22 |
@@ -82,23 +83,23 @@ __ieee754_acos(double x) |
| 23 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
| 24 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
| 25 |
r = p/q; |
| 26 |
return pio2_hi - (x - (pio2_lo-x*r)); |
| 27 |
} else if (hx<0) { /* x < -0.5 */ |
| 28 |
z = (one+x)*0.5; |
| 29 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
| 30 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
| 31 |
- s = sqrt(z); |
| 32 |
+ s = std::sqrt(z); |
| 33 |
r = p/q; |
| 34 |
w = r*s-pio2_lo; |
| 35 |
return pi - 2.0*(s+w); |
| 36 |
} else { /* x > 0.5 */ |
| 37 |
z = (one-x)*0.5; |
| 38 |
- s = sqrt(z); |
| 39 |
+ s = std::sqrt(z); |
| 40 |
df = s; |
| 41 |
SET_LOW_WORD(df,0); |
| 42 |
c = (z-df*df)/(s+df); |
| 43 |
p = z*(pS0+z*(pS1+z*(pS2+z*(pS3+z*(pS4+z*pS5))))); |
| 44 |
q = one+z*(qS1+z*(qS2+z*(qS3+z*qS4))); |
| 45 |
r = p/q; |
| 46 |
w = r*s+c; |
| 47 |
return 2.0*(df+w); |
| 48 |
diff --git a/e_acosh.cpp b/e_acosh.cpp |
| 49 |
--- a/e_acosh.cpp |
| 50 |
+++ b/e_acosh.cpp |
| 51 |
@@ -24,16 +24,17 @@ |
| 52 |
* acosh(x) := log(2x-1/(sqrt(x*x-1)+x)) if x>2; else |
| 53 |
* acosh(x) := log1p(t+sqrt(2.0*t+t*t)); where t=x-1. |
| 54 |
* |
| 55 |
* Special cases: |
| 56 |
* acosh(x) is NaN with signal if x<1. |
| 57 |
* acosh(NaN) is NaN without signal. |
| 58 |
*/ |
| 59 |
|
| 60 |
+#include <cmath> |
| 61 |
#include <float.h> |
| 62 |
|
| 63 |
#include "math_private.h" |
| 64 |
|
| 65 |
static const double |
| 66 |
one = 1.0, |
| 67 |
ln2 = 6.93147180559945286227e-01; /* 0x3FE62E42, 0xFEFA39EF */ |
| 68 |
|
| 69 |
@@ -50,14 +51,14 @@ __ieee754_acosh(double x) |
| 70 |
if(hx >=0x7ff00000) { /* x is inf of NaN */ |
| 71 |
return x+x; |
| 72 |
} else |
| 73 |
return __ieee754_log(x)+ln2; /* acosh(huge)=log(2x) */ |
| 74 |
} else if(((hx-0x3ff00000)|lx)==0) { |
| 75 |
return 0.0; /* acosh(1) = 0 */ |
| 76 |
} else if (hx > 0x40000000) { /* 2**28 > x > 2 */ |
| 77 |
t=x*x; |
| 78 |
- return __ieee754_log(2.0*x-one/(x+sqrt(t-one))); |
| 79 |
+ return __ieee754_log(2.0*x-one/(x+std::sqrt(t-one))); |
| 80 |
} else { /* 1<x<2 */ |
| 81 |
t = x-one; |
| 82 |
- return log1p(t+sqrt(2.0*t+t*t)); |
| 83 |
+ return log1p(t+std::sqrt(2.0*t+t*t)); |
| 84 |
} |
| 85 |
} |
| 86 |
diff --git a/e_asin.cpp b/e_asin.cpp |
| 87 |
--- a/e_asin.cpp |
| 88 |
+++ b/e_asin.cpp |
| 89 |
@@ -39,16 +39,17 @@ |
| 90 |
* = pio4_hi+(pio4-2f)-(2s*z*R(z)-(pio2_lo+2c)) |
| 91 |
* |
| 92 |
* Special cases: |
| 93 |
* if x is NaN, return x itself; |
| 94 |
* if |x|>1, return NaN with invalid signal. |
| 95 |
* |
| 96 |
*/ |
| 97 |
|
| 98 |
+#include <cmath> |
| 99 |
#include <float.h> |
| 100 |
|
| 101 |
#include "math_private.h" |
| 102 |
|
| 103 |
static const double |
| 104 |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
| 105 |
huge = 1.000e+300, |
| 106 |
pio2_hi = 1.57079632679489655800e+00, /* 0x3FF921FB, 0x54442D18 */ |
| 107 |
@@ -90,17 +91,17 @@ __ieee754_asin(double x) |
| 108 |
w = p/q; |
| 109 |
return x+x*w; |
| 110 |
} |
| 111 |
/* 1> |x|>= 0.5 */ |
| 112 |
w = one-fabs(x); |
| 113 |
t = w*0.5; |
| 114 |
p = t*(pS0+t*(pS1+t*(pS2+t*(pS3+t*(pS4+t*pS5))))); |
| 115 |
q = one+t*(qS1+t*(qS2+t*(qS3+t*qS4))); |
| 116 |
- s = sqrt(t); |
| 117 |
+ s = std::sqrt(t); |
| 118 |
if(ix>=0x3FEF3333) { /* if |x| > 0.975 */ |
| 119 |
w = p/q; |
| 120 |
t = pio2_hi-(2.0*(s+s*w)-pio2_lo); |
| 121 |
} else { |
| 122 |
w = s; |
| 123 |
SET_LOW_WORD(w,0); |
| 124 |
c = (t-w*w)/(s+w); |
| 125 |
r = p/q; |
| 126 |
diff --git a/e_hypot.cpp b/e_hypot.cpp |
| 127 |
--- a/e_hypot.cpp |
| 128 |
+++ b/e_hypot.cpp |
| 129 |
@@ -41,16 +41,17 @@ |
| 130 |
* hypot(x,y) is INF if x or y is +INF or -INF; else |
| 131 |
* hypot(x,y) is NAN if x or y is NAN. |
| 132 |
* |
| 133 |
* Accuracy: |
| 134 |
* hypot(x,y) returns sqrt(x^2+y^2) with error less |
| 135 |
* than 1 ulps (units in the last place) |
| 136 |
*/ |
| 137 |
|
| 138 |
+#include <cmath> |
| 139 |
#include <float.h> |
| 140 |
|
| 141 |
#include "math_private.h" |
| 142 |
|
| 143 |
double |
| 144 |
__ieee754_hypot(double x, double y) |
| 145 |
{ |
| 146 |
double a,b,t1,t2,y1,y2,w; |
| 147 |
@@ -100,25 +101,25 @@ __ieee754_hypot(double x, double y) |
| 148 |
} |
| 149 |
} |
| 150 |
/* medium size a and b */ |
| 151 |
w = a-b; |
| 152 |
if (w>b) { |
| 153 |
t1 = 0; |
| 154 |
SET_HIGH_WORD(t1,ha); |
| 155 |
t2 = a-t1; |
| 156 |
- w = sqrt(t1*t1-(b*(-b)-t2*(a+t1))); |
| 157 |
+ w = std::sqrt(t1*t1-(b*(-b)-t2*(a+t1))); |
| 158 |
} else { |
| 159 |
a = a+a; |
| 160 |
y1 = 0; |
| 161 |
SET_HIGH_WORD(y1,hb); |
| 162 |
y2 = b - y1; |
| 163 |
t1 = 0; |
| 164 |
SET_HIGH_WORD(t1,ha+0x00100000); |
| 165 |
t2 = a - t1; |
| 166 |
- w = sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
| 167 |
+ w = std::sqrt(t1*y1-(w*(-w)-(t1*y2+t2*b))); |
| 168 |
} |
| 169 |
if(k!=0) { |
| 170 |
t1 = 0.0; |
| 171 |
SET_HIGH_WORD(t1,(1023+k)<<20); |
| 172 |
return t1*w; |
| 173 |
} else return w; |
| 174 |
} |
| 175 |
diff --git a/e_pow.cpp b/e_pow.cpp |
| 176 |
--- a/e_pow.cpp |
| 177 |
+++ b/e_pow.cpp |
| 178 |
@@ -52,16 +52,17 @@ |
| 179 |
* |
| 180 |
* Constants : |
| 181 |
* The hexadecimal values are the intended ones for the following |
| 182 |
* constants. The decimal values may be used, provided that the |
| 183 |
* compiler will convert from decimal to binary accurately enough |
| 184 |
* to produce the hexadecimal values shown. |
| 185 |
*/ |
| 186 |
|
| 187 |
+#include <cmath> |
| 188 |
#include <float.h> |
| 189 |
#include "math_private.h" |
| 190 |
|
| 191 |
static const double |
| 192 |
bp[] = {1.0, 1.5,}, |
| 193 |
dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */ |
| 194 |
dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */ |
| 195 |
zero = 0.0, |
| 196 |
@@ -151,17 +152,17 @@ __ieee754_pow(double x, double y) |
| 197 |
return (hy<0)?-y: zero; |
| 198 |
} |
| 199 |
if(iy==0x3ff00000) { /* y is +-1 */ |
| 200 |
if(hy<0) return one/x; else return x; |
| 201 |
} |
| 202 |
if(hy==0x40000000) return x*x; /* y is 2 */ |
| 203 |
if(hy==0x3fe00000) { /* y is 0.5 */ |
| 204 |
if(hx>=0) /* x >= +0 */ |
| 205 |
- return sqrt(x); |
| 206 |
+ return std::sqrt(x); |
| 207 |
} |
| 208 |
} |
| 209 |
|
| 210 |
ax = fabs(x); |
| 211 |
/* special value of x */ |
| 212 |
if(lx==0) { |
| 213 |
if(ix==0x7ff00000||ix==0||ix==0x3ff00000){ |
| 214 |
z = ax; /*x is +-0,+-inf,+-1*/ |
| 215 |
diff --git a/s_asinh.cpp b/s_asinh.cpp |
| 216 |
--- a/s_asinh.cpp |
| 217 |
+++ b/s_asinh.cpp |
| 218 |
@@ -19,16 +19,17 @@ |
| 219 |
* asinh(x) = sign(x) * log [ |x| + sqrt(x*x+1) ] |
| 220 |
* we have |
| 221 |
* asinh(x) := x if 1+x*x=1, |
| 222 |
* := sign(x)*(log(x)+ln2)) for large |x|, else |
| 223 |
* := sign(x)*log(2|x|+1/(|x|+sqrt(x*x+1))) if|x|>2, else |
| 224 |
* := sign(x)*log1p(|x| + x^2/(1 + sqrt(1+x^2))) |
| 225 |
*/ |
| 226 |
|
| 227 |
+#include <cmath> |
| 228 |
#include <float.h> |
| 229 |
|
| 230 |
#include "math_private.h" |
| 231 |
|
| 232 |
static const double |
| 233 |
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */ |
| 234 |
ln2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */ |
| 235 |
huge= 1.00000000000000000000e+300; |
| 236 |
@@ -43,15 +44,15 @@ asinh(double x) |
| 237 |
if(ix>=0x7ff00000) return x+x; /* x is inf or NaN */ |
| 238 |
if(ix< 0x3e300000) { /* |x|<2**-28 */ |
| 239 |
if(huge+x>one) return x; /* return x inexact except 0 */ |
| 240 |
} |
| 241 |
if(ix>0x41b00000) { /* |x| > 2**28 */ |
| 242 |
w = __ieee754_log(fabs(x))+ln2; |
| 243 |
} else if (ix>0x40000000) { /* 2**28 > |x| > 2.0 */ |
| 244 |
t = fabs(x); |
| 245 |
- w = __ieee754_log(2.0*t+one/(__ieee754_sqrt(x*x+one)+t)); |
| 246 |
+ w = __ieee754_log(2.0*t+one/(std::sqrt(x*x+one)+t)); |
| 247 |
} else { /* 2.0 > |x| > 2**-28 */ |
| 248 |
t = x*x; |
| 249 |
- w =log1p(fabs(x)+t/(one+__ieee754_sqrt(one+t))); |
| 250 |
+ w =log1p(fabs(x)+t/(one+std::sqrt(one+t))); |
| 251 |
} |
| 252 |
if(hx>0) return w; else return -w; |
| 253 |
} |
| 254 |
--- a/e_asinf.cpp 2022-12-13 14:45:17.953154257 -0500 |
| 255 |
+++ b/e_asinf.cpp 2022-12-13 14:45:03.425091710 -0500 |
| 256 |
@@ -11,16 +11,18 @@ |
| 257 |
* software is freely granted, provided that this notice |
| 258 |
* is preserved. |
| 259 |
* ==================================================== |
| 260 |
*/ |
| 261 |
|
| 262 |
//#include <sys/cdefs.h> |
| 263 |
//__FBSDID("$FreeBSD$"); |
| 264 |
|
| 265 |
+#include <cmath> |
| 266 |
+ |
| 267 |
#include "math_private.h" |
| 268 |
|
| 269 |
static const float |
| 270 |
one = 1.0000000000e+00, /* 0x3F800000 */ |
| 271 |
huge = 1.000e+30, |
| 272 |
/* coefficient for R(x^2) */ |
| 273 |
pS0 = 1.6666586697e-01, |
| 274 |
pS1 = -4.2743422091e-02, |
| 275 |
@@ -52,13 +54,13 @@ |
| 276 |
w = p/q; |
| 277 |
return x+x*w; |
| 278 |
} |
| 279 |
/* 1> |x|>= 0.5 */ |
| 280 |
w = one-fabsf(x); |
| 281 |
t = w*(float)0.5; |
| 282 |
p = t*(pS0+t*(pS1+t*pS2)); |
| 283 |
q = one+t*qS1; |
| 284 |
- s = sqrt(t); |
| 285 |
+ s = std::sqrt(t); |
| 286 |
w = p/q; |
| 287 |
t = pio2-2.0*(s+s*w); |
| 288 |
if(hx>0) return t; else return -t; |
| 289 |
} |