consteig
Compile-time eigenvalue and eigenvector computation for C++17
Loading...
Searching...
No Matches
abs.hpp
1#ifndef CONSTMATH_ABS_HPP
2#define CONSTMATH_ABS_HPP
3
4namespace consteig
5{
6
9
17template <typename T> constexpr T abs(const T x)
18{
19 return (
20 // if 0 is signed
21 x == T(0) ? T(0) :
22 // else
23 x < T(0) ? -x
24 : x);
25}
26
28
29} // namespace consteig
30
31#endif
constexpr T abs(const T x)
Absolute value of a real number.
Definition abs.hpp:17
constexpr T epsilon()
Machine epsilon for type T.
Definition utilities.hpp:82