dot-xx
A personal collection of small C++ modules
Loading...
Searching...
No Matches
norm.xx File Reference

Vector norms. More...

Classes

struct  dxx::math::Norm< Func, SqFunc >
 Defines a norm. Only norm field is required, all other fields can be assigned a nullptr More...

Namespaces

namespace  dxx::math
 The main namespace of the dxx::math module.
namespace  dxx::math::norms
 Built-in norms.

Functions

template<Norm t_norm = norms::euclidean, vector V>
constexpr RealOf< V > dxx::math::norm (const V &v)
 Calculates norm t_norm for vector v
template<Norm t_norm = norms::euclidean, vector V>
constexpr RealOf< V > dxx::math::sq_norm (const V &v)
 Calculates the square of the norm t_norm for vector v
template<Norm t_norm = norms::euclidean, vector V, vector_like< V > U>
constexpr RealOf< V > dxx::math::dist (const V &v, const U &u)
 Calculates the distance between vector v and u according to norm t_norm
template<Norm t_norm = norms::euclidean, vector V, vector_like< V > U>
constexpr RealOf< V > dxx::math::sq_dist (const V &v, const U &u)
 Calculates the square of the distance between vector v and u according to norm t_norm

Variables

constexpr auto dxx::math::detail::euclidean_squared
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

Vector norms.

Variable Documentation

◆ euclidean_squared

auto dxx::math::detail::euclidean_squared
inlineconstexpr
Initial value:
= [] (const vector auto& v) static {
return dot(v, v);
}
We can treat any input range as a vector.
Definition traits.xx:16