6#ifndef CHEBYSHEV_DISTANCE_H
7#define CHEBYSHEV_DISTANCE_H
20 template<
typename Type = real_t>
23 const Type diff = b - a;
24 const prec_t result =
prec_t(diff < Type(0.0) ? -diff : diff);
33 template<
typename Vector>
36 if (v1.size() != v2.size() || !v1.size())
39 auto sum = (v1[0] - v2[0]) * (v1[0] - v2[0]);
40 for (
size_t i = 1; i < v1.size(); i++) {
41 sum += (v1[i] - v2[i]) * (v1[i] - v2[i]);
44 return std::sqrt(sum);
50 inline unsigned int hamming(
const std::string& a,
const std::string& b) {
53 for (
size_t i = 0; i < std::min(a.size(), b.size()); i++)
57 if (a.size() != b.size())
58 sum += std::abs(
int(a.size()) -
int(b.size()));
long double prec_t
Floating-point type of higher precision, used in computations, such as error estimation.
Definition common.h:42
Distance functions for use in prec_context::equals().
unsigned int hamming(const std::string &a, const std::string &b)
Hamming distance between two strings, defined as the number of positions at which the corresponding c...
Definition distance.h:50
prec_t euclidean(const Vector &v1, const Vector &v2)
Euclidean distance between vectors (any type with a size() method and [] operator).
Definition distance.h:34
prec_t absolute(Type a, Type b)
Absolute distance between two values which have an ordering with respect to zero.
Definition distance.h:21
General namespace of the framework.
Definition benchmark.h:22
constexpr FloatType get_nan()
Get a quiet NaN of the specified floating point type.
Definition common.h:65