13 #ifndef MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP 14 #define MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP 43 static inline bool IsBetter(
const double value,
const double ref)
45 return (value <= ref);
53 template<
typename TreeType>
55 const TreeType* referenceNode);
63 template<
typename TreeType>
65 const TreeType* referenceNode,
66 const double centerToCenterDistance);
80 template<
typename TreeType>
82 const TreeType* referenceNode,
83 const TreeType* referenceChildNode,
84 const double centerToCenterDistance);
91 template<
typename VecType,
typename TreeType>
93 const TreeType* referenceNode);
101 template<
typename VecType,
typename TreeType>
103 const TreeType* referenceNode,
104 const double pointToCenterDistance);
110 template<
typename VecType,
typename TreeType>
111 static size_t GetBestChild(
const VecType& queryPoint, TreeType& referenceNode)
113 return referenceNode.GetNearestChild(queryPoint);
120 template<
typename TreeType>
121 static size_t GetBestChild(
const TreeType& queryNode, TreeType& referenceNode)
123 return referenceNode.GetNearestChild(queryNode);
149 return std::max(a - b, 0.0);
157 if (a == DBL_MAX || b == DBL_MAX)
170 static inline double Relax(
const double value,
const double epsilon)
172 if (value == DBL_MAX)
174 return (1 / (1 + epsilon)) * value;
static double Relax(const double value, const double epsilon)
Return the given value relaxed.
Definition: nearest_neighbor_sort.hpp:170
static double BestDistance()
Return what should represent the best possible distance with this particular sort policy...
Definition: nearest_neighbor_sort.hpp:142
static double WorstDistance()
Return what should represent the worst possible distance with this particular sort policy...
Definition: nearest_neighbor_sort.hpp:133
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static double ConvertToScore(const double distance)
Convert the given distance into a score.
Definition: nearest_neighbor_sort.hpp:182
static double ConvertToDistance(const double score)
Convert the given score to a distance.
Definition: nearest_neighbor_sort.hpp:192
static double CombineWorst(const double a, const double b)
Return the worst combination of the two distances.
Definition: nearest_neighbor_sort.hpp:155
The core includes that mlpack expects; standard C++ includes and Armadillo.
static size_t GetBestChild(const TreeType &queryNode, TreeType &referenceNode)
Return the best child according to this sort policy.
Definition: nearest_neighbor_sort.hpp:121
static double CombineBest(const double a, const double b)
Return the best combination of the two distances.
Definition: nearest_neighbor_sort.hpp:147
static bool IsBetter(const double value, const double ref)
Return whether or not value is "better" than ref.
Definition: nearest_neighbor_sort.hpp:43
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
Definition: nearest_neighbor_sort.hpp:31
static double BestPointToNodeDistance(const VecType &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.
Definition: nearest_neighbor_sort_impl.hpp:50
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
Definition: nearest_neighbor_sort_impl.hpp:20
static size_t GetBestChild(const VecType &queryPoint, TreeType &referenceNode)
Return the best child according to this sort policy.
Definition: nearest_neighbor_sort.hpp:111