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_COMPLEX_FUNCTIONS_SIGN_H
4#define pRC_CORE_COMPLEX_FUNCTIONS_SIGN_H
5
9
10namespace pRC
11{
12 template<class T, If<IsInvocable<Sign, T>> = 0>
13 static inline constexpr auto sign(Complex<T> const &a)
14 {
15 if(a.real() == zero() && a.imag() == zero())
16 {
17 return zero<Complex<T>>();
18 }
19 else
20 {
21 return a / abs(a);
22 }
23 }
24}
25#endif // pRC_CORE_COMPLEX_FUNCTIONS_SIGN_H
Definition complex.hpp:26
constexpr decltype(auto) real() &&
Definition complex.hpp:125
constexpr decltype(auto) imag() &&
Definition complex.hpp:145
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
static constexpr auto abs(Complex< T > const &a)
Definition abs.hpp:12