9#include <dune/common/math.hh>
17 constexpr T abs(T
const& a)
19 return a < 0 ? -a : a;
25 constexpr auto sqr(T
const& a)
31 template <
int p,
class T>
32 constexpr auto pow(T
const& v)
34 static_assert( p >= 0,
"Exponent p in `pow<p>(v)` should be >= 0," );
35 return Dune::power(v,p);
43 template <
class T0,
class T1>
44 constexpr auto min(T0 a, T1 b)
46 using T = std::common_type_t<T0,T1>;
47 return T(a) < T(b) ? a : b;
51 constexpr T0 min(T0 a)
56 template <
class T0,
class... Ts>
57 constexpr auto min(T0 a, Ts... ts)
59 return min(a, min(ts...));
69 template <
class T0,
class T1>
70 constexpr auto max(T0 a, T1 b)
72 using T = std::common_type_t<T0,T1>;
73 return T(a) < T(b) ? b : a;
77 constexpr T0 max(T0 a)
82 template <
class T0,
class... Ts>
83 constexpr auto max(T0 a, Ts... ts)
85 return max(a, max(ts...));
91 constexpr double sum()
96 template <
class... Ts>
97 constexpr auto sum(Ts
const&... ts)
105 constexpr T threshold = std::numeric_limits<T>::epsilon();