akreon-linalg
Fixed-size linear algebra and numerical methods in C++26.
Loading...
Searching...
No Matches
matrix_norms.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
10#include "norm_traits.hpp"
11
12namespace linalg {
13
23template <MatrixContainer Mat>
24struct Fro {
28
29 constexpr codomain_type operator()(const domain_type& matrix) const {
31 for (std::size_t row = 0; row < mat_rows_v<domain_type>; ++row)
32 for (std::size_t col = 0; col < mat_cols_v<domain_type>; ++col) {
33 if constexpr (Real<scalar_type>)
34 result += matrix(row, col) * matrix(row, col);
35 else result += (std::conj(matrix(row, col)) * matrix(row, col)).real();
36 }
38 }
39};
40
41template <MatrixContainer Mat>
49
50} // namespace linalg
Field classified by scalar_traits as real.
std::remove_cvref_t< T > remove_cvref_t
Remove top-level const, volatile, and reference qualification.
typename scalar_traits_t< T >::real_type real_type_t
Associated real component type registered for T.
constexpr T constexpr_sqrt_safe(T x, T floor=T(0), T g=1e-10, T tol=1e-10)
Return a scalar square root with a sanitized fallback radicand.
constexpr std::size_t mat_rows_v
Registered compile-time row count after cv/ref normalization.
typename mat_traits< remove_cvref_t< Mat > >::value_type matrix_scalar_t
Registered matrix scalar type after cv/ref normalization.
compute the frobenius norm of a matrix
constexpr codomain_type operator()(const domain_type &matrix) const
remove_cvref_t< Mat > domain_type
matrix_scalar_t< domain_type > scalar_type
real_type_t< scalar_type > codomain_type
remove_cvref_t< Mat > domain_type
matrix_scalar_t< domain_type > scalar_type
real_type_t< scalar_type > codomain_type
declaring norm traits