Skip to content

Commit 39eadff

Browse files
committed
fix exp
1 parent 1f97c94 commit 39eadff

File tree

1 file changed

+14
-14
lines changed
  • libc/src/__support/math

1 file changed

+14
-14
lines changed

libc/src/__support/math/exp.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ using Float128 = typename fputil::DyadicFloat<128>;
3636
using LIBC_NAMESPACE::operator""_u128;
3737

3838
// log2(e)
39-
static constexpr double LOG2_E = 0x1.71547652b82fep+0;
39+
static double LOG2_E = 0x1.71547652b82fep+0;
4040

4141
// Error bounds:
4242
// Errors when using double precision.
43-
static constexpr double ERR_D = 0x1.8p-63;
43+
static double ERR_D = 0x1.8p-63;
4444

4545
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
4646
// Errors when using double-double precision.
47-
static constexpr double ERR_DD = 0x1.0p-99;
47+
static double ERR_DD = 0x1.0p-99;
4848
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
4949

5050
// -2^-12 * log(2)
@@ -53,12 +53,12 @@ static constexpr double ERR_DD = 0x1.0p-99;
5353
// > c = round(a - b, 30, RN);
5454
// > d = round(a - b - c, D, RN);
5555
// Errors < 1.5 * 2^-133
56-
static constexpr double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
57-
static constexpr double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
56+
static double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
57+
static double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
5858

5959
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
60-
static constexpr double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
61-
static constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
60+
static double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
61+
static double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
6262
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
6363

6464
namespace {
@@ -67,7 +67,7 @@ namespace {
6767
// Return expm1(dx) / x ~ 1 + dx / 2 + dx^2 / 6 + dx^3 / 24.
6868
// For |dx| < 2^-13 + 2^-30:
6969
// | output - expm1(dx) / dx | < 2^-51.
70-
static constexpr double poly_approx_d(double dx) {
70+
static double poly_approx_d(double dx) {
7171
// dx^2
7272
double dx2 = dx * dx;
7373
// c0 = 1 + dx / 2
@@ -85,7 +85,7 @@ static constexpr double poly_approx_d(double dx) {
8585
// Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^6 / 720
8686
// For |dx| < 2^-13 + 2^-30:
8787
// | output - exp(dx) | < 2^-101
88-
static constexpr DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
88+
static DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
8989
// Taylor polynomial.
9090
constexpr DoubleDouble COEFFS[] = {
9191
{0, 0x1p0}, // 1
@@ -106,7 +106,7 @@ static constexpr DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
106106
// Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^7 / 5040
107107
// For |dx| < 2^-13 + 2^-30:
108108
// | output - exp(dx) | < 2^-126.
109-
static constexpr Float128 poly_approx_f128(const Float128 &dx) {
109+
static Float128 poly_approx_f128(const Float128 &dx) {
110110
constexpr Float128 COEFFS_128[]{
111111
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
112112
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
@@ -127,7 +127,7 @@ static constexpr Float128 poly_approx_f128(const Float128 &dx) {
127127
// Compute exp(x) using 128-bit precision.
128128
// TODO(lntue): investigate triple-double precision implementation for this
129129
// step.
130-
static constexpr Float128 exp_f128(double x, double kd, int idx1, int idx2) {
130+
static Float128 exp_f128(double x, double kd, int idx1, int idx2) {
131131
// Recalculate dx:
132132

133133
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -160,7 +160,7 @@ static constexpr Float128 exp_f128(double x, double kd, int idx1, int idx2) {
160160
}
161161

162162
// Compute exp(x) with double-double precision.
163-
static constexpr DoubleDouble exp_double_double(double x, double kd,
163+
static DoubleDouble exp_double_double(double x, double kd,
164164
const DoubleDouble &exp_mid) {
165165
// Recalculate dx:
166166
// dx = x - k * 2^-12 * log(2)
@@ -184,7 +184,7 @@ static constexpr DoubleDouble exp_double_double(double x, double kd,
184184

185185
// Check for exceptional cases when
186186
// |x| <= 2^-53 or x < log(2^-1075) or x >= 0x1.6232bdd7abcd3p+9
187-
static constexpr double set_exceptional(double x) {
187+
static double set_exceptional(double x) {
188188
using FPBits = typename fputil::FPBits<double>;
189189
FPBits xbits(x);
190190

@@ -234,7 +234,7 @@ static constexpr double set_exceptional(double x) {
234234

235235
namespace math {
236236

237-
static constexpr double exp(double x) {
237+
static double exp(double x) {
238238
using FPBits = typename fputil::FPBits<double>;
239239
FPBits xbits(x);
240240

0 commit comments

Comments
 (0)