pRC
multi-purpose Tensor Train library for C++
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{
25 template<class T, If<IsValue<T>> = 0,
26 If<IsSatisfied<(typename T::Signed() == true)>> = 0>
27 static inline constexpr auto sign(T const &a)
28 {
29 if(a < zero())
30 {
31 return -identity<T>();
32 }
33
34 if(a > zero())
35 {
36 return identity<T>();
37 }
38
39 return zero<T>();
40 }
41
53 template<class T, If<IsValue<T>> = 0,
54 If<IsSatisfied<(typename T::Signed() == false)>> = 0>
55 static inline constexpr auto sign(T const &a)
56 {
57 if(a > zero())
58 {
59 return identity<T>();
60 }
61
62 return zero<T>();
63 }
64}
65#endif // pRC_CORE_VALUE_FUNCTIONS_SIGN_H
Definition cholesky.hpp:18
static constexpr auto zero()
Definition zero.hpp:12
static constexpr auto sign(Complex< T > const &a)
Definition sign.hpp:13
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13