cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
sign.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_VALUE_FUNCTIONS_SIGN_H
4#define pRC_CORE_VALUE_FUNCTIONS_SIGN_H
5
11
12namespace pRC
13{
14 template<class T, If<IsValue<T>> = 0,
15 If<IsSatisfied<(typename T::Signed() == true)>> = 0>
16 static inline constexpr auto sign(T const &a)
17 {
18 if(a < zero())
19 {
20 return -identity<T>();
21 }
22
23 if(a > zero())
24 {
25 return identity<T>();
26 }
27
28 return zero<T>();
29 }
30
31 template<class T, If<IsValue<T>> = 0,
32 If<IsSatisfied<(typename T::Signed() == false)>> = 0>
33 static inline constexpr auto sign(T const &a)
34 {
35 if(a > zero())
36 {
37 return identity<T>();
38 }
39
40 return zero<T>();
41 }
42}
43#endif // pRC_CORE_VALUE_FUNCTIONS_SIGN_H
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
static constexpr auto zero()
Definition zero.hpp:12
static constexpr auto sign(Complex< T > const &a)
Definition sign.hpp:13