MLPACK  1.0.11
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,
59  const arma::Col<size_t>& indices,
60  double newDistance);
61 
71  static inline bool IsBetter(const double value, const double ref)
72  {
73  return (value < ref);
74  }
75 
81  template<typename TreeType>
82  static double BestNodeToNodeDistance(const TreeType* queryNode,
83  const TreeType* referenceNode);
84 
91  template<typename TreeType>
92  static double BestNodeToNodeDistance(const TreeType* queryNode,
93  const TreeType* referenceNode,
94  const double centerToCenterDistance);
95 
108  template<typename TreeType>
109  static double BestNodeToNodeDistance(const TreeType* queryNode,
110  const TreeType* referenceNode,
111  const TreeType* referenceChildNode,
112  const double centerToCenterDistance);
118  template<typename VecType, typename TreeType>
119  static double BestPointToNodeDistance(const VecType& queryPoint,
120  const TreeType* referenceNode);
121 
128  template<typename VecType, typename TreeType>
129  static double BestPointToNodeDistance(const VecType& queryPoint,
130  const TreeType* referenceNode,
131  const double pointToCenterDistance);
132 
140  static inline double WorstDistance() { return DBL_MAX; }
141 
149  static inline double BestDistance() { return 0.0; }
150 
154  static inline double CombineBest(const double a, const double b)
155  {
156  return std::max(a - b, 0.0);
157  }
158 
162  static inline double CombineWorst(const double a, const double b)
163  {
164  if (a == DBL_MAX || b == DBL_MAX)
165  return DBL_MAX;
166  return a + b;
167  }
168 };
169 
170 }; // namespace neighbor
171 }; // namespace mlpack
172 
173 // Include implementation of templated functions.
174 #include "nearest_neighbor_sort_impl.hpp"
175 
176 #endif