diff --git a/src/lib/netlist/nl_util.h b/src/lib/netlist/nl_util.h index 9b3b33b875f..50c545c22e3 100644 --- a/src/lib/netlist/nl_util.h +++ b/src/lib/netlist/nl_util.h @@ -41,30 +41,34 @@ private: nl_math() {}; public: - ATTR_HOT inline static float exp(const float &x) { return std::exp(x); } + template + static T abs(const T &x) { return std::abs(x); } - ATTR_HOT inline static double abs(const double &x) { return std::abs(x); } - ATTR_HOT inline static float abs(const float &x) { return std::abs(x); } + template + static T max(const T &x, const T &y) { return std::max(x, y); } - ATTR_HOT inline static double max(const double &x, const double &y) { return std::max(x, y); } - ATTR_HOT inline static float max(const float &x, const float &y) { return std::max(x, y); } + template + static T min(const T &x, const T &y) { return std::min(x, y); } - ATTR_HOT inline static double log(const double &x) { return std::log(x); } - ATTR_HOT inline static float log(const float &x) { return std::log(x); } -#if defined(_MSC_VER) && _MSC_VER < 1800 + template + static T log(const T &x) { return std::log(x); } + + #if defined(_MSC_VER) && _MSC_VER < 1800 ATTR_HOT inline static double e_log1p(const double &x) { return nl_math::log(1.0 + x); } ATTR_HOT inline static float e_log1p(const float &x) { return nl_math::log(1.0 + x); } #else - ATTR_HOT inline static double e_log1p(const double &x) { return log1p(x); } - ATTR_HOT inline static float e_log1p(const float &x) { return log1pf(x); } + template + static T e_log1p(const T &x) { return log1p(x); } #endif - ATTR_HOT inline static double sqrt(const double &x) { return std::sqrt(x); } - ATTR_HOT inline static float sqrt(const float &x) { return std::sqrt(x); } + + template + static T sqrt(const T &x) { return std::sqrt(x); } // this one has an accuracy of better than 5%. That's enough for our purpose // add c3 and it'll be better than 1% #if 0 + ATTR_HOT inline static float exp(const float &x) { return std::exp(x); } inline static double fastexp_h(const double &x) { /* static */ const double ln2r = 1.442695040888963387; @@ -93,7 +97,8 @@ public: return fastexp_h(x); } #else - ATTR_HOT inline static double exp(const double &x) { return std::exp(x); } + template + static double exp(const T &x) { return std::exp(x); } #endif };