knncolle
Collection of KNN methods in C++
Loading...
Searching...
No Matches
Static Public Member Functions | List of all members
knncolle::MockDistance Struct Reference

Expectations for a distance calculation class. More...

#include <distances.hpp>

Static Public Member Functions

template<typename Output_ , typename DataX_ , typename DataY_ , typename Dim_ >
static Output_ raw_distance (const DataX_ *x, const DataY_ *y, Dim_ num_dimensions)
 
template<typename Output_ >
static Output_ normalize (Output_ raw)
 
template<typename Output_ >
static Output_ denormalize (Output_ norm)
 

Detailed Description

Expectations for a distance calculation class.

Member Function Documentation

◆ denormalize()

template<typename Output_ >
static Output_ knncolle::MockDistance::denormalize ( Output_  norm)
inlinestatic
Template Parameters
Output_Floating point type for the output distance.
Parameters
normNormalized distance (i.e., the output of normalize()).
Returns
The denormalized distance (i.e., the input to normalize()).

◆ normalize()

template<typename Output_ >
static Output_ knncolle::MockDistance::normalize ( Output_  raw)
inlinestatic
Template Parameters
Output_Floating point type for the output distance.
Parameters
rawRaw distance.
Returns
The normalized distance.

◆ raw_distance()

template<typename Output_ , typename DataX_ , typename DataY_ , typename Dim_ >
static Output_ knncolle::MockDistance::raw_distance ( const DataX_ *  x,
const DataY_ *  y,
Dim_  num_dimensions 
)
inlinestatic

The raw distance r for a distance d is defined so that r(x, y) > r(x, z) iff d(x, y) > d(x, z). r(x, y) is converted to d(x, z) via a monotonic transform in normalize(), and vice versa for denormalize(). We separate out these two steps to avoid, e.g., a costly root operation for a Euclidean distance when only the relative values are of interest.

Parameters
xPointer to the array containing the first vector.
yPointer to the array containing the second vector.
num_dimensionsLength of both vectors.
Template Parameters
Output_Floating point type for the output distance.
DataX_Floating point type for the first data vector.
DataY_Floating point type for the second data vector.
Dim_Integer type for the vector length.
Returns
The raw distance between x and y.

The documentation for this struct was generated from the following file: