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
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...
static size_t SortDistance(const arma::vec &list, const arma::Col< size_t > &indices, double newDistance)
Return the index in the vector where the new distance should be inserted, or (size_t() - 1) if it sho...
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
static bool IsBetter(const double value, const double ref)
Return whether or not value is "better" than ref.
static double BestPointToNodeDistance(const VecType &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.
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.