Skip to content

Commit a8cb524

Browse files
committed
fix exp
1 parent 1f97c94 commit a8cb524

File tree

1 file changed

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

1 file changed

+7
-7
lines changed

libc/src/__support/math/exp.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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)