consteig
Compile-time eigenvalue and eigenvector computation for C++17
Loading...
Searching...
No Matches
include
consteig
math
functions
sgn.hpp
1
#ifndef CONSTMATH_SGN_HPP
2
#define CONSTMATH_SGN_HPP
3
4
namespace
consteig
5
{
6
9
15
template
<
typename
T>
constexpr
T
sgn
(
const
T
x
)
16
{
17
return
(
// positive
18
x
>
static_cast<
T
>
(0) ?
static_cast<
T
>
(1) :
19
// negative
20
x < static_cast<T>
(0) ?
static_cast<
T
>
(-1)
21
:
22
// else
23
static_cast<
T
>
(0));
24
}
25
27
28
}
// namespace consteig
29
30
#endif
consteig::sgn
constexpr T sgn(const T x)
Signum function: returns +1, -1, or 0.
Definition
sgn.hpp:15
consteig::epsilon
constexpr T epsilon()
Machine epsilon for type T.
Definition
utilities.hpp:82
Generated by
1.10.0