maths: move more operations into util::
This commit is contained in:
parent
7b083df977
commit
89fe57b65b
@ -75,7 +75,7 @@ template uint64_t log2 (uint64_t);
|
||||
template <typename T>
|
||||
double
|
||||
rootsquare (T a, T b)
|
||||
{ return sqrt (pow2 (a) + pow2 (b)); }
|
||||
{ return sqrt (util::pow2 (a) + util::pow2 (b)); }
|
||||
|
||||
|
||||
template double rootsquare (double, double);
|
||||
|
22
maths.hpp
22
maths.hpp
@ -26,14 +26,16 @@
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
namespace util {
|
||||
template <typename T>
|
||||
T
|
||||
abs (T value)
|
||||
{ return value > 0 ? value : -value; }
|
||||
|
||||
|
||||
namespace util {
|
||||
template <typename T> T abs (T t) { return ::abs<T> (t); }
|
||||
abs [[gnu::const]] (T t)
|
||||
{
|
||||
return t > 0 ? t : -t;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,17 +49,11 @@ namespace util {
|
||||
{ return value * value; }
|
||||
}
|
||||
|
||||
template <typename T> constexpr T pow2 [[gnu::const]] (T value) { return util::pow2 (value); }
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
namespace util {
|
||||
template <typename T>
|
||||
constexpr T
|
||||
pow [[gnu::const]] (T x, unsigned y);
|
||||
|
||||
namespace util {
|
||||
|
||||
template <typename T>
|
||||
constexpr T pow (T x, unsigned y) { return ::pow (x, y); }
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user