1 #ifndef DataFormatsMathAPPROX_EXP_H
2 #define DataFormatsMathAPPROX_EXP_H
44 return float(0x2.p0) +
y * (float(0x2.07b99p0) +
y * float(0x1.025b84p0));
49 #ifdef HORNER // HORNER
50 return float(0x2.p0) +
y * (float(0x1.fff798p0) +
y * (float(0x1.02249p0) +
y * float(0x5.62042p-4)));
52 float p23 = (float(0x1.02249p0) +
y * float(0x5.62042p-4));
53 float p01 = float(0x2.p0) +
y * float(0x1.fff798p0);
54 return p01 +
y *
y * p23;
60 return float(0x2.p0) +
61 y * (float(0x1.fffb1p0) +
y * (float(0xf.ffe84p-4) +
y * (float(0x5.5f9c1p-4) +
y * float(0x1.57755p-4))));
66 return float(0x2.p0) +
67 y * (float(0x2.p0) +
y * (float(0xf.ffed8p-4) +
68 y * (float(0x5.5551cp-4) +
y * (float(0x1.5740d8p-4) +
y * float(0x4.49368p-8)))));
73 #ifdef HORNER // HORNER
77 y * (float(0x1.p0) +
y * (float(0x5.55523p-4) +
y * (float(0x1.5554dcp-4) +
78 y * (float(0x4.48f41p-8) +
y * float(0xb.6ad4p-12))))));
79 #else // ESTRIN does seem to save a cycle or two
80 float p56 = float(0x4.48f41p-8) +
y * float(0xb.6ad4p-12);
81 float p34 = float(0x5.55523p-4) +
y * float(0x1.5554dcp-4);
83 float p12 = float(0x2.p0) +
y;
84 float p36 = p34 + y2 * p56;
85 float p16 = p12 + y2 * p36;
86 float p = float(0x2.p0) + y * p16;
94 return float(0x2.p0) +
97 y * (float(0x5.55555p-4) +
98 y * (float(0x1.5554e4p-4) +
99 y * (float(0x4.444adp-8) +
y * (float(0xb.6a8a6p-12) +
y * float(0x1.9ec814p-12)))))));
124 template <
int DEGREE>
126 using namespace approx_math;
137 constexpr
float inv_log2f = float(0x1.715476p0);
138 constexpr
float log2H = float(0xb.172p-4);
139 constexpr
float log2L = float(0x1.7f7d1cp-20);
143 float z =
fpfloor((x * inv_log2f) + 0.5
f);
158 float p = approx_expf_P<DEGREE>(y);
162 uint32_t biased_exponent =
e + 127;
163 ef.ui32 = (biased_exponent << 23);
168 #ifndef NO_APPROX_MATH
170 template <
int DEGREE>
172 return unsafe_expf_impl<DEGREE>(
x);
175 template <
int DEGREE>
177 constexpr
float inf_threshold = float(0x5.8b90cp4);
179 constexpr
float zero_threshold_ftz = -float(0x5.75628p4);
184 float r = unsafe_expf<DEGREE>(
x);
190 template <
int DEGREE>
194 template <
int DEGREE>
198 #endif // NO_APPROX_MATH
constexpr float approx_expf_P(float p)
constexpr float fpfloor(float x)
Exp< T >::type exp(const T &t)
constexpr float approx_expf_P< 5 >(float y)
uint16_t const *__restrict__ x
constexpr float approx_expf_P< 2 >(float y)
constexpr float approx_expf_P< 6 >(float y)
constexpr float approx_expf(float x)
constexpr float approx_expf_P< 3 >(float y)
constexpr float unsafe_expf(float x)
constexpr float approx_expf_P< 4 >(float y)
constexpr float unsafe_expf_impl(float x)
constexpr float approx_expf_P< 7 >(float y)