akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
norm_traits.hpp
Go to the documentation of this file.
1/*
2 * Copyright © 2025-2026 Akreon LLC
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
6#pragma once
7
8namespace linalg {
9
11template <FieldVector Vec>
12struct L2;
13
15template <FieldVector Vec>
16struct L1;
17
19template <FieldVector Vec>
20struct Linf;
21
23template <class Norm>
24struct norm_traits : std::false_type {};
25
27template <FieldVector Vec>
28struct norm_traits<L2<Vec>> : std::true_type {
32 static constexpr std::size_t dim = vector_dim_v<domain_type>;
33};
34
36template <FieldVector Vec>
37struct norm_traits<L1<Vec>> : std::true_type {
41 static constexpr std::size_t dim = vector_dim_v<domain_type>;
42};
43
45template <FieldVector Vec>
46struct norm_traits<Linf<Vec>> : std::true_type {
50 static constexpr std::size_t dim = vector_dim_v<domain_type>;
51};
52
54template <class Norm>
56
57template <class Norm>
59
60template <class Norm>
62
63template <class Norm>
65
66template <class Norm>
67inline constexpr std::size_t norm_dim_v = norm_traits_t<Norm>::dim;
68
70template <class Norm>
72
74template <class Candidate>
75concept NormFunction =
78 { norm(value) } -> std::same_as<norm_codomain_t<Candidate>>;
79 };
80
81} // namespace linalg
concept for norm like
std::remove_cvref_t< T > remove_cvref_t
Remove top-level const, volatile, and reference qualification.
typename vector_traits_t< Vec >::element_type vector_element_t
Registered vector coordinate type.
typename scalar_traits_t< T >::real_type real_type_t
Associated real component type registered for T.
typename norm_traits_t< Norm >::scalar_type norm_scalar_t
typename norm_traits_t< Norm >::codomain_type norm_codomain_t
constexpr bool is_norm_v
helper for is norm type
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
constexpr std::size_t norm_dim_v
typename norm_traits_t< Norm >::domain_type norm_domain_t
forward declaration for L1 norm
forward declaration for L2 norm
forward declaration for Linf norm
vector_element_t< domain_type > scalar_type
real_type_t< scalar_type > codomain_type
remove_cvref_t< Vec > domain_type
real_type_t< scalar_type > codomain_type
vector_element_t< domain_type > scalar_type
remove_cvref_t< Vec > domain_type
vector_element_t< domain_type > scalar_type
real_type_t< scalar_type > codomain_type
remove_cvref_t< Vec > domain_type
declaring norm traits