cMHN 1.2
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<IsValue T>
15 static inline constexpr auto sign(T const &a)
16 {
17 if(a < zero())
18 {
19 return -identity<T>();
20 }
21
22 if(a > zero())
23 {
24 return identity<T>();
25 }
26
27 return zero<T>();
28 }
29
30 template<IsValue T>
31 requires IsUnsignedInteger<T>
32 static inline constexpr auto sign(T const &a)
33 {
34 if(a > zero())
35 {
36 return identity<T>();
37 }
38
39 return zero<T>();
40 }
41}
42#endif // pRC_CORE_VALUE_FUNCTIONS_SIGN_H
Definition value.hpp:12
Definition cholesky.hpp:10
static constexpr auto sign(T const &a)
Definition sign.hpp:11
static constexpr auto identity()
Definition identity.hpp:13
static constexpr auto zero()
Definition zero.hpp:12