cMHN 1.1
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_VALUE_FUNCTIONS_NORM_H
4#define pRC_CORE_VALUE_FUNCTIONS_NORM_H
5
9
10namespace pRC
11{
12 template<Index P = 2, Index Q = P, class T, If<IsValue<T>> = 0>
13 static inline constexpr auto norm(T const &a)
14 {
15 if constexpr(P == Q)
16 {
17 return abs(a);
18 }
19 else if constexpr(P == 2 && Q == 1)
20 {
21 return square(a);
22 }
23 else if constexpr(Q == 0)
24 {
25 return norm<P, P>(a);
26 }
27 else
28 {
29 static_assert(P != P, "Unsupported p-norm.");
30 }
31 }
32}
33#endif // pRC_CORE_VALUE_FUNCTIONS_NORM_H
Definition cholesky.hpp:18
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
static constexpr auto square(Complex< T > const &a)
Definition square.hpp:14
static constexpr auto abs(Complex< T > const &a)
Definition abs.hpp:12
static constexpr auto norm(Complex< T > const &a)
Definition norm.hpp:11