diff --git a/libs/math/benchmarks/benchmark_fast.cpp b/libs/math/benchmarks/benchmark_fast.cpp index 7b02dfa7df..3c3c3ba201 100644 --- a/libs/math/benchmarks/benchmark_fast.cpp +++ b/libs/math/benchmarks/benchmark_fast.cpp @@ -145,11 +145,6 @@ struct StdExp2dot2Log { float operator()(float v) { return std::exp(2.2f * std::log(v)); } static const char* label() { return "std::exp(2.2f * std::log(x))"; } }; -struct FastPow2dot2 { - using result_type = float; - float operator()(float v) { return fast::pow2dot2(v); } - static const char* label() { return "fast::pow2dot2"; } -}; struct Float16 { using result_type = half; @@ -176,7 +171,5 @@ BENCHMARK_TEMPLATE(BM_func, Vector, FastISqrt); BENCHMARK_TEMPLATE(BM_func, Scalar, StdPow2dot2); BENCHMARK_TEMPLATE(BM_func, Scalar, StdExp2dot2Log); -BENCHMARK_TEMPLATE(BM_func, Scalar, FastPow2dot2); -BENCHMARK_TEMPLATE(BM_func, Vector, FastPow2dot2); BENCHMARK_TEMPLATE(BM_func, Scalar, Float16); diff --git a/libs/math/include/math/fast.h b/libs/math/include/math/fast.h index 616a2d1a53..7e1e55b0cf 100644 --- a/libs/math/include/math/fast.h +++ b/libs/math/include/math/fast.h @@ -57,7 +57,7 @@ constexpr inline float MATH_PURE ilog2(float x) noexcept { float val; int32_t x; } u = { x }; - return ((u.x >> 23) & 0xff) - 127; + return float(((u.x >> 23) & 0xff) - 127); } constexpr inline float MATH_PURE log2(float x) noexcept { @@ -122,28 +122,6 @@ constexpr float exp(float x) noexcept { return float(exp(double(x))); } -inline float MATH_PURE pow(float a, float b) noexcept { - constexpr int fudgeMinRMSE = 486411; - constexpr int K = (127 << 23) - fudgeMinRMSE; - union { - float f; - int x; - } u = { a }; - u.x = (int)(b * (u.x - K) + K); - return u.f; -} - -// this is more precise than pow() above -inline float MATH_PURE pow2dot2(float a) noexcept { - union { - float f; - int x; - } u = { a }; - constexpr int K = (127 << 23); - u.x = (int)(0.2f * (u.x - K) + K); - return a * a * u.f; // a^2 * a^0.2 -} - /* * unsigned saturated arithmetic */