MLPACK  1.0.8
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