dot-xx
A personal collection of small C++ modules
Loading...
Searching...
No Matches
dxx::math::norms Namespace Reference

Built-in norms. More...

Variables

constexpr Norm dxx::math::norms::euclidean
 Euclidean norm (2-norm)
constexpr Norm dxx::math::norms::p_one
 1-norm (sum of absolute values of elements)
constexpr Norm dxx::math::norms::infinity
 Infinity norm (max absolute value across elements)

Detailed Description

Built-in norms.

Variable Documentation

◆ euclidean

Norm dxx::math::norms::euclidean
inlineconstexprexport
Initial value:
{
.norm = [] (const vector auto& v) static {
return std::sqrt(detail::euclidean_squared(v));
},
.sq_norm = detail::euclidean_squared,
}
We can treat any input range as a vector.
Definition traits.xx:16

Euclidean norm (2-norm)

◆ infinity

Norm dxx::math::norms::infinity
inlineconstexprexport
Initial value:
{
.norm = [] <vector V> (const V& v) static {
RealOf<V> ret{};
for (const auto& ve : v) {
const auto ave = std::abs(ve);
if (ave > ret) {
ret = ave;
}
}
return ret;
},
}
detail::RealOf< T >::Type RealOf
(Non-cv-qualified) Real type of the linalg type
Definition traits.xx:40

Infinity norm (max absolute value across elements)

◆ p_one

Norm dxx::math::norms::p_one
inlineconstexprexport
Initial value:
{
.norm = [] <vector V> (const V& v) static {
RealOf<V> ret{};
for (const auto& ve : v) {
ret += std::abs(ve);
}
return ret;
},
}

1-norm (sum of absolute values of elements)