diff --git a/maths.cpp b/maths.cpp index 4e681b4a..2d9cc7fc 100644 --- a/maths.cpp +++ b/maths.cpp @@ -25,15 +25,7 @@ #include -template -T -pow2 (T value) - { return value * value; } - -template double pow2(double); -template int pow2( int); - - +//----------------------------------------------------------------------------- template bool is_pow2 (T value) { @@ -41,21 +33,25 @@ is_pow2 (T value) { return (return_type)(value && !(value & (value - 1))); } + template bool is_pow2 (uint8_t); template bool is_pow2 (uint16_t); template bool is_pow2 (uint32_t); template bool is_pow2 (uint64_t); +//----------------------------------------------------------------------------- template double rootsquare (T a, T b) { return sqrt (pow2 (a) + pow2 (b)); } + template double rootsquare (double, double); template double rootsquare ( int, int); +//----------------------------------------------------------------------------- template bool is_integer (const T &value) { @@ -64,6 +60,7 @@ is_integer (const T &value) { static_cast (0.0)); } + template bool is_integer (const double&); template bool is_integer (const float&); @@ -80,6 +77,7 @@ almost_equal (const double &a, const double &b) { return ieee_double::almost_equal (a, b); } +//----------------------------------------------------------------------------- template typename std::enable_if::value, T>::type round_up (T value, T align) { @@ -88,6 +86,7 @@ round_up (T value, T align) { } +//----------------------------------------------------------------------------- template T round_pow2 (T value) { @@ -110,6 +109,7 @@ template uint32_t round_pow2 (uint32_t); template uint64_t round_pow2 (uint64_t); +//----------------------------------------------------------------------------- template int sign (T val) { diff --git a/maths.hpp b/maths.hpp index d8f748b1..a15d210d 100644 --- a/maths.hpp +++ b/maths.hpp @@ -25,8 +25,9 @@ #include template -T -pow2 (T value) pure; +constexpr T +pow2 (T value) + { return value * value; } template