knncolle
Collection of KNN methods in C++
Loading...
Searching...
No Matches
knncolle::DistanceMetric< Data_, Distance_ > Class Template Referenceabstract

Interface for a distance metric. More...

#include <distances.hpp>

Inheritance diagram for knncolle::DistanceMetric< Data_, Distance_ >:

Public Member Functions

virtual Distance_ raw (size_t num_dimensions, const Data_ *x, const Data_ *y) const =0
 
virtual Distance_ normalize (Distance_ raw) const =0
 
virtual Distance_ denormalize (Distance_ norm) const =0
 

Detailed Description

template<typename Data_, typename Distance_>
class knncolle::DistanceMetric< Data_, Distance_ >

Interface for a distance metric.

Template Parameters
Distance_Floating-point type for the output distance.
Data_Numeric type for the input data.

Member Function Documentation

◆ denormalize()

template<typename Data_ , typename Distance_ >
virtual Distance_ knncolle::DistanceMetric< Data_, Distance_ >::denormalize ( Distance_ norm) const
pure virtual
Parameters
normNormalized distance (i.e., the output of normalize()).
Returns
The denormalized distance (i.e., the input to normalize()).

◆ normalize()

template<typename Data_ , typename Distance_ >
virtual Distance_ knncolle::DistanceMetric< Data_, Distance_ >::normalize ( Distance_ raw) const
pure virtual
Parameters
rawRaw distance.
Returns
The normalized distance.

◆ raw()

template<typename Data_ , typename Distance_ >
virtual Distance_ knncolle::DistanceMetric< Data_, Distance_ >::raw ( size_t num_dimensions,
const Data_ * x,
const Data_ * y ) const
pure virtual

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.
Returns
The raw distance between x and y.

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