mirror of
https://github.com/holub/mame
synced 2025-04-26 18:23:08 +03:00
Use templates in nl_math.
This commit is contained in:
parent
fc31cd6289
commit
7d2c7a125e
@ -41,30 +41,34 @@ private:
|
|||||||
nl_math() {};
|
nl_math() {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ATTR_HOT inline static float exp(const float &x) { return std::exp(x); }
|
template <typename T>
|
||||||
|
static T abs(const T &x) { return std::abs(x); }
|
||||||
|
|
||||||
ATTR_HOT inline static double abs(const double &x) { return std::abs(x); }
|
template <typename T>
|
||||||
ATTR_HOT inline static float abs(const float &x) { return std::abs(x); }
|
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); }
|
template <typename T>
|
||||||
ATTR_HOT inline static float max(const float &x, const float &y) { return std::max(x, y); }
|
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); }
|
template <typename T>
|
||||||
ATTR_HOT inline static float log(const float &x) { return std::log(x); }
|
static T log(const T &x) { return std::log(x); }
|
||||||
#if defined(_MSC_VER) && _MSC_VER < 1800
|
|
||||||
|
#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 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); }
|
ATTR_HOT inline static float e_log1p(const float &x) { return nl_math::log(1.0 + x); }
|
||||||
#else
|
#else
|
||||||
ATTR_HOT inline static double e_log1p(const double &x) { return log1p(x); }
|
template <typename T>
|
||||||
ATTR_HOT inline static float e_log1p(const float &x) { return log1pf(x); }
|
static T e_log1p(const T &x) { return log1p(x); }
|
||||||
#endif
|
#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 <typename T>
|
||||||
|
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
|
// this one has an accuracy of better than 5%. That's enough for our purpose
|
||||||
// add c3 and it'll be better than 1%
|
// add c3 and it'll be better than 1%
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
ATTR_HOT inline static float exp(const float &x) { return std::exp(x); }
|
||||||
inline static double fastexp_h(const double &x)
|
inline static double fastexp_h(const double &x)
|
||||||
{
|
{
|
||||||
/* static */ const double ln2r = 1.442695040888963387;
|
/* static */ const double ln2r = 1.442695040888963387;
|
||||||
@ -93,7 +97,8 @@ public:
|
|||||||
return fastexp_h(x);
|
return fastexp_h(x);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
ATTR_HOT inline static double exp(const double &x) { return std::exp(x); }
|
template <typename T>
|
||||||
|
static double exp(const T &x) { return std::exp(x); }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user