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;
206 #include "nearest_neighbor_sort_impl.hpp" static double CombineWorst(const double a, const double b)
Return the worst combination of the two distances.
static double ConvertToDistance(const double score)
Convert the given score to a distance.
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static double ConvertToScore(const double distance)
Convert the given distance into a score.
static size_t GetBestChild(const VecType &queryPoint, TreeType &referenceNode)
Return the best child according to this sort policy.
static double BestPointToNodeDistance(const VecType &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.
static bool IsBetter(const double value, const double ref)
Return whether or not value is "better" than ref.
static double WorstDistance()
Return what should represent the worst possible distance with this particular sort policy...
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
static double Relax(const double value, const double epsilon)
Return the given value relaxed.
static double BestDistance()
Return what should represent the best possible distance with this particular sort policy...
static size_t GetBestChild(const TreeType &queryNode, TreeType &referenceNode)
Return the best child according to this sort policy.
static double CombineBest(const double a, const double b)
Return the best combination of the two distances.