nk 1.0.0
C++ Numerical Computing Runtime
Loading...
Searching...
No Matches
norms.hpp
Go to the documentation of this file.
1
3// toolboxes/linalg/include/nk/linalg/norms.hpp
4//
5// Vector and matrix norms. Migrated from toolboxes/builtin/src/language/
6// arrays/{matrix,predicates}.cpp.
7//
8// `norm` for the matrix 2-norm (p == 2) routes through `svd_values`,
9// which still lives in toolboxes/builtin/include/nk/builtin/language/
10// arrays/matrix.hpp at this point — that header is included by the
11// implementation TU (norms.cpp). When SVD migrates here in a later
12// group, this include will switch over to nk/linalg/decomp/svd.hpp.
13
14#pragma once
15
16#include <memory_resource>
17#include <nk/value/value.hpp>
18
19namespace nk::linalg {
20
23
24
37Value norm_value(const Value &x, double p, std::pmr::memory_resource *mr = nullptr);
38
42Value norm_inf(const Value &x, std::pmr::memory_resource *mr = nullptr);
43
47Value norm_fro(const Value &x, std::pmr::memory_resource *mr = nullptr);
48
59Value vecnorm(const Value &A, double p = 2.0, int dim = 0, std::pmr::memory_resource *mr = nullptr);
60
61
63} // namespace nk::linalg
Core MATLAB-compatible multidimensional array and scalar value type.
Definition value.hpp:61
Value norm_fro(const Value &x, std::pmr::memory_resource *mr=nullptr)
Frobenius norm (n = norm(A, 'fro')).
Value norm_inf(const Value &x, std::pmr::memory_resource *mr=nullptr)
Inf-norm (n = norm(x, inf)).
Value norm_value(const Value &x, double p, std::pmr::memory_resource *mr=nullptr)
Vector / matrix p-norm (n = norm(x, p)).
Value vecnorm(const Value &A, double p=2.0, int dim=0, std::pmr::memory_resource *mr=nullptr)
Vector p-norm along a dim (y = vecnorm(A, p, dim)).