cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
norm.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_COMPLEX_FUNCTIONS_NORM_H
4#define pRC_CORE_COMPLEX_FUNCTIONS_NORM_H
5
7
8namespace pRC
9{
10 template<Index P, Index Q = P, IsComplex T>
11 requires(P == 1 && Q == 1)
12 static inline constexpr auto norm(T const &a)
13 {
14 return abs(a.real()) + abs(a.imag());
15 }
16
17 template<Index P, Index Q, IsComplex T>
18 requires(P == 2 && Q == 1)
19 static inline constexpr auto norm(T const &a)
20 {
21 return a.real() * a.real() + a.imag() * a.imag();
22 }
23
24 template<Index P = 2, Index Q = P, IsComplex T>
25 requires(P == 2 && Q == 2)
26 static inline constexpr auto norm(T const &a)
27 {
28 return sqrt(norm<2, 1>(a));
29 }
30}
31#endif // pRC_CORE_COMPLEX_FUNCTIONS_NORM_H
Definition value.hpp:12
Definition cholesky.hpp:10
static constexpr auto sqrt(T const &a)
Definition sqrt.hpp:11
static constexpr auto abs(T const &a)
Definition abs.hpp:11
static constexpr auto norm(T const &a)
Definition norm.hpp:12