1#ifndef KNNCOLLE_DISTANCES_HPP
2#define KNNCOLLE_DISTANCES_HPP
34 template<
typename Output_,
typename DataX_,
typename DataY_,
typename Dim_>
35 static Output_
raw_distance(
const DataX_* x,
const DataY_* y, Dim_ num_dimensions) {
37 for (Dim_ d = 0; d < num_dimensions; ++d, ++x, ++y) {
38 auto delta =
static_cast<Output_
>(*x) - *y;
39 output += delta * delta;
49 template<
typename Output_>
59 template<
typename Output_>
82 template<
typename Output_,
typename DataX_,
typename DataY_,
typename Dim_>
83 static Output_
raw_distance(
const DataX_* x,
const DataY_* y, Dim_ num_dimensions) {
85 for (Dim_ d = 0; d < num_dimensions; ++d, ++x, ++y) {
86 auto delta =
static_cast<Output_
>(*x) -
static_cast<Output_
>(*y);
87 output += delta * delta;
97 template<
typename Output_>
99 return std::sqrt(raw);
107 template<
typename Output_>
130 template<
typename Output_,
typename DataX_,
typename DataY_,
typename Dim_>
131 static Output_
raw_distance(
const DataX_* x,
const DataY_* y, Dim_ num_dimensions) {
133 for (Dim_ d = 0; d < num_dimensions; ++d, ++x, ++y) {
134 output += std::abs(
static_cast<Output_
>(*x) -
static_cast<Output_
>(*y));
144 template<
typename Output_>
154 template<
typename Output_>
Collection of KNN algorithms.
Definition Bruteforce.hpp:22
Compute Euclidean distances between two input vectors.
Definition distances.hpp:68
static Output_ raw_distance(const DataX_ *x, const DataY_ *y, Dim_ num_dimensions)
Definition distances.hpp:83
static Output_ denormalize(Output_ norm)
Definition distances.hpp:108
static Output_ normalize(Output_ raw)
Definition distances.hpp:98
Compute Manhattan distances between two input vectors.
Definition distances.hpp:116
static Output_ denormalize(Output_ norm)
Definition distances.hpp:155
static Output_ normalize(Output_ raw)
Definition distances.hpp:145
static Output_ raw_distance(const DataX_ *x, const DataY_ *y, Dim_ num_dimensions)
Definition distances.hpp:131
Expectations for a distance calculation class.
Definition distances.hpp:17
static Output_ raw_distance(const DataX_ *x, const DataY_ *y, Dim_ num_dimensions)
Definition distances.hpp:35
static Output_ normalize(Output_ raw)
Definition distances.hpp:50
static Output_ denormalize(Output_ norm)
Definition distances.hpp:60