8#ifndef THEORETICA_DISTANCE_H
9#define THEORETICA_DISTANCE_H
13#include "../core/constants.h"
14#include "../core/core_traits.h"
15#include "../core/real_analysis.h"
16#include "../complex/complex_analysis.h"
33 template<
typename Vector>
38 for (
unsigned int i = 0; i < v.size(); ++i)
50 template<
typename Vector>
55 for (
unsigned int i = 0; i < v.size(); ++i)
66 template<
typename Vector>
71 for (
unsigned int i = 1; i < v.size(); ++i)
83 template<
typename Vector>
88 for (
unsigned int i = 1; i < v.size(); ++i)
104 template<
typename Vector>
107 if(
v1.size() !=
v2.size()) {
122 template<
unsigned int N>
158 return (
z1 -
z2).norm();
169 template<
typename Vector>
172 if(
v1.size() !=
v2.size()) {
199 template<
typename Vector,
typename T = real>
202 if(
v1.size() !=
v2.size()) {
209 for (
size_t i = 0; i <
v1.size(); ++i) {
224 template<
unsigned int N,
typename T>
238 template<
typename Vector>
241 if(
v1.size() !=
v2.size()) {
256 template<
typename Vector>
259 if(
v1.size() !=
v2.size()) {
275 template<
typename Vector>
279 if(
v1.size() !=
v2.size()) {
286 for (
size_t i = 0; i <
v1.size(); ++i) {
305 template<
typename Vector>
308 if(
v1.size() !=
v2.size()) {
315 for (
size_t i = 0; i <
v1.size(); ++i)
327 template<
typename Vector>
330 if(
v1.size() !=
v2.size()) {
339 for (
size_t i = 0; i <
v1.size(); ++i) {
356 template<
typename Vector>
360 if(
v1.size() !=
v2.size()) {
365 unsigned int count = 0;
368 for (
unsigned int i = 0; i <
v1.size(); ++i)
A statically allocated N-dimensional vector with elements of the given type.
Definition vec.h:92
#define TH_MATH_ERROR(F_NAME, VALUE, EXCEPTION)
TH_MATH_ERROR is a macro which throws exceptions or modifies errno (depending on which compiling opti...
Definition error.h:225
real l2_norm(const Vector &v)
Compute the L2 norm of a vector: .
Definition distance.h:67
real discrete_distance(const Vector &v1, const Vector &v2, real tolerance=MACH_EPSILON)
Compute the discrete distance between two vectors.
Definition distance.h:276
real l1_norm(const Vector &v)
Compute the L1 norm of a vector: .
Definition distance.h:51
real minkowski_distance(const Vector &v1, const Vector &v2, unsigned int p)
Compute the Minkowski distance between two vectors: .
Definition distance.h:170
real manhattan_distance(const Vector &v1, const Vector &v2)
Compute the Manhattan distance between two vectors: .
Definition distance.h:239
real euclidean_distance(const Vector &v1, const Vector &v2)
Distances.
Definition distance.h:105
real cosine_distance(const Vector &v1, const Vector &v2)
Compute the cosine distance between two vectors.
Definition distance.h:328
auto pair_inner_product(const Type &v_i, const Type &w_i)
Compute the contribution of the inner product between a pair of elements of two vectors,...
Definition algebra.h:252
auto hermitian_distance(const Vector &v1, const Vector &v2)
Compute the Hermitian distance between two vectors: .
Definition distance.h:200
real linf_norm(const Vector &v)
Compute the Linf norm of a vector: .
Definition distance.h:84
real canberra_distance(const Vector &v1, const Vector &v2)
Compute the Canberra distance between two vectors.
Definition distance.h:306
real lp_norm(const Vector &v, unsigned int p)
Norms.
Definition distance.h:34
real hamming_distance(const Vector &v1, const Vector &v2, real tolerance=MACH_EPSILON)
Compute the Hamming distance between two vectors.
Definition distance.h:357
real distance(const vec< real, N > &v1, const vec< real, N > &v2)
Compute the Euclidean distance between two vectors: .
Definition distance.h:123
real chebyshev_distance(const Vector &v1, const Vector &v2)
Compute the Chebyshev distance between two vectors: .
Definition distance.h:257
Main namespace of the library which contains all functions and objects.
Definition algebra.h:27
double real
A real number, defined as a floating point type.
Definition constants.h:198
dual2 sqrt(dual2 x)
Compute the square root of a second order dual number.
Definition dual2_functions.h:54
dual2 abs(dual2 x)
Compute the absolute value of a second order dual number.
Definition dual2_functions.h:198
std::remove_reference_t< decltype(std::declval< Structure >()[0])> vector_element_t
Extract the type of a vector (or any indexable container) from its operator[].
Definition core_traits.h:134
auto sum(const Vector &X)
Compute the sum of a vector of real values using pairwise summation to reduce round-off error.
Definition dataset.h:219
dual2 conjugate(dual2 x)
Return the conjugate of a second order dual number.
Definition dual2_functions.h:35
auto max(const Vector &X)
Finds the maximum value inside a dataset.
Definition dataset.h:330
TH_CONSTEXPR real nan()
Return a quiet NaN number in floating point representation.
Definition error.h:54
constexpr real MACH_EPSILON
Machine epsilon for the real type.
Definition constants.h:207
real root(real x, int n)
Compute the n-th root of x.
Definition real_analysis.h:812
auto product(const Vector &X)
Compute the product of a set of values.
Definition dataset.h:29
dual2 square(dual2 x)
Return the square of a second order dual number.
Definition dual2_functions.h:23
dual2 pow(dual2 x, int n)
Compute the n-th power of a second order dual number.
Definition dual2_functions.h:41
Vector class and operations.