MLPACK  1.0.7
nearest_neighbor_sort.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
24 #define __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
25 
26 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace neighbor {
30 
42 {
43  public:
58  static size_t SortDistance(const arma::vec& list, double newDistance);
59 
69  static inline bool IsBetter(const double value, const double ref)
70  {
71  return (value < ref);
72  }
73 
79  template<typename TreeType>
80  static double BestNodeToNodeDistance(const TreeType* queryNode,
81  const TreeType* referenceNode);
82 
89  template<typename TreeType>
90  static double BestNodeToNodeDistance(const TreeType* queryNode,
91  const TreeType* referenceNode,
92  const double centerToCenterDistance);
93 
106  template<typename TreeType>
107  static double BestNodeToNodeDistance(const TreeType* queryNode,
108  const TreeType* referenceNode,
109  const TreeType* referenceChildNode,
110  const double centerToCenterDistance);
116  template<typename TreeType>
117  static double BestPointToNodeDistance(const arma::vec& queryPoint,
118  const TreeType* referenceNode);
119 
126  template<typename TreeType>
127  static double BestPointToNodeDistance(const arma::vec& queryPoint,
128  const TreeType* referenceNode,
129  const double pointToCenterDistance);
130 
138  static inline double WorstDistance() { return DBL_MAX; }
139 
147  static inline double BestDistance() { return 0.0; }
148 
152  static inline double CombineBest(const double a, const double b)
153  {
154  return std::max(a - b, 0.0);
155  }
156 
160  static inline double CombineWorst(const double a, const double b)
161  {
162  if (a == DBL_MAX || b == DBL_MAX)
163  return DBL_MAX;
164  return a + b;
165  }
166 };
167 
168 }; // namespace neighbor
169 }; // namespace mlpack
170 
171 // Include implementation of templated functions.
172 #include "nearest_neighbor_sort_impl.hpp"
173 
174 #endif
static double CombineWorst(const double a, const double b)
Return the worst combination of the two distances.
static double CombineBest(const double a, const double b)
Return the best combination of the two distances.
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 size_t SortDistance(const arma::vec &list, double newDistance)
Return the index in the vector where the new distance should be inserted, or (size_t() - 1) if it sho...
static bool IsBetter(const double value, const double ref)
Return whether or not value is &quot;better&quot; than ref.
static double BestDistance()
Return what should represent the best possible distance with this particular sort policy...
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
static double BestPointToNodeDistance(const arma::vec &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.