Theoretica
A C++ numerical and automatic mathematical library
distance.h File Reference

Distances and norms of generic vectors, with real or complex elements. More...

Go to the source code of this file.

Namespaces

 theoretica
 Main namespace of the library which contains all functions and objects.
 
 theoretica::algebra
 Linear algebra routines.
 

Functions

template<typename Vector >
real theoretica::algebra::lp_norm (const Vector &v, unsigned int p)
 Norms. More...
 
template<typename Vector >
real theoretica::algebra::l1_norm (const Vector &v)
 Compute the L1 norm of a vector: \(L_1(\vec v) = \Sigma_i \ |v_i|\). More...
 
template<typename Vector >
real theoretica::algebra::l2_norm (const Vector &v)
 Compute the L2 norm of a vector: \(L_2(\vec v) = \sqrt{\Sigma_i \ v_i^2}\). More...
 
template<typename Vector >
real theoretica::algebra::linf_norm (const Vector &v)
 Compute the Linf norm of a vector: \(L_{\infty}(\vec v) = max(|v_i|)\). More...
 
template<typename Vector >
real theoretica::algebra::euclidean_distance (const Vector &v1, const Vector &v2)
 Distances. More...
 
template<unsigned int N>
real theoretica::algebra::distance (const vec< real, N > &v1, const vec< real, N > &v2)
 Compute the Euclidean distance between two vectors: \(d(\vec v_1, \vec v_2) = L_2(\vec v_1 - \vec v_2)\). More...
 
real theoretica::algebra::euclidean_distance (real a, real b)
 Compute the Euclidian distance between two real values: \(d(a, b) = |a - b|\). More...
 
real theoretica::algebra::distance (real a, real b)
 Compute the Euclidian distance between two values: \(d(a, b) = |a - b|\). More...
 
template<typename T >
complex< T > theoretica::algebra::distance (complex< T > z1, complex< T > z2)
 Compute the distance between two complex numbers: \(d(z_1, z_2) = |z_1 - z_2|\). More...
 
template<typename Vector >
real theoretica::algebra::minkowski_distance (const Vector &v1, const Vector &v2, unsigned int p)
 Compute the Minkowski distance between two vectors: \(d(\vec v_1, \vec v_2) = L_p(\vec v_1 - \vec v_2)\). More...
 
real theoretica::algebra::minkowski_distance (real a, real b, unsigned int p)
 Compute the Minkowski distance between two values: \(d(a, b) = L_p(a - b)\). More...
 
template<typename Vector , typename T = real>
auto theoretica::algebra::hermitian_distance (const Vector &v1, const Vector &v2)
 Compute the Hermitian distance between two vectors: \(d(\vec v_1, \vec v_2) = (\vec v_1 - \vec v_2) \cdot (\vec v_1 - \vec v_2)^*\). More...
 
template<unsigned int N, typename T >
complex< T > theoretica::algebra::distance (const vec< complex< T >, N > &v1, const vec< complex< T >, N > &v2)
 Compute the Hermitian distance between two vectors: \(d(\vec v_1, \vec v_2) = (\vec v_1 - \vec v_2) \cdot (\vec v_1 - \vec v_2)^*\). More...
 
template<typename Vector >
real theoretica::algebra::manhattan_distance (const Vector &v1, const Vector &v2)
 Compute the Manhattan distance between two vectors: \(d(\vec v_1, \vec v_2) = L_1(\vec v_1 - \vec v_2)\). More...
 
template<typename Vector >
real theoretica::algebra::chebyshev_distance (const Vector &v1, const Vector &v2)
 Compute the Chebyshev distance between two vectors: \(d(\vec v_1, \vec v_2) = L_{\infty}(\vec v_1 - \vec v_2)\). More...
 
template<typename Vector >
real theoretica::algebra::discrete_distance (const Vector &v1, const Vector &v2, real tolerance=MACH_EPSILON)
 Compute the discrete distance between two vectors. More...
 
template<typename Vector >
real theoretica::algebra::canberra_distance (const Vector &v1, const Vector &v2)
 Compute the Canberra distance between two vectors. More...
 
template<typename Vector >
real theoretica::algebra::cosine_distance (const Vector &v1, const Vector &v2)
 Compute the cosine distance between two vectors. More...
 
template<typename Vector >
real theoretica::algebra::hamming_distance (const Vector &v1, const Vector &v2, real tolerance=MACH_EPSILON)
 Compute the Hamming distance between two vectors. More...
 

Detailed Description

Distances and norms of generic vectors, with real or complex elements.

The element type of the vectors needs to have a function abs() which returns a real number.