MLPACK  1.0.11
furthest_neighbor_sort.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_HPP
24 #define __MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_HPP
25 
26 #include <mlpack/core.hpp>
27 
28 namespace mlpack {
29 namespace neighbor {
30 
38 {
39  public:
54  static size_t SortDistance(const arma::vec& list,
55  const arma::Col<size_t>& indices,
56  double newDistance);
57 
67  static inline bool IsBetter(const double value, const double ref)
68  {
69  return (value > ref);
70  }
71 
77  template<typename TreeType>
78  static double BestNodeToNodeDistance(const TreeType* queryNode,
79  const TreeType* referenceNode);
80 
87  template<typename TreeType>
88  static double BestNodeToNodeDistance(const TreeType* queryNode,
89  const TreeType* referenceNode,
90  const double centerToCenterDistance);
91 
104  template<typename TreeType>
105  static double BestNodeToNodeDistance(const TreeType* queryNode,
106  const TreeType* referenceNode,
107  const TreeType* referenceChildNode,
108  const double centerToCenterDistance);
109 
115  template<typename VecType, typename TreeType>
116  static double BestPointToNodeDistance(const VecType& queryPoint,
117  const TreeType* referenceNode);
118 
125  template<typename VecType, typename TreeType>
126  static double BestPointToNodeDistance(const VecType& queryPoint,
127  const TreeType* referenceNode,
128  const double pointToCenterDistance);
129 
137  static inline double WorstDistance() { return 0; }
138 
146  static inline double BestDistance() { return DBL_MAX; }
147 
151  static inline double CombineBest(const double a, const double b)
152  {
153  if (a == DBL_MAX || b == DBL_MAX)
154  return DBL_MAX;
155  return a + b;
156  }
157 
161  static inline double CombineWorst(const double a, const double b)
162  { return std::max(a - b, 0.0); }
163 };
164 
165 }; // namespace neighbor
166 }; // namespace mlpack
167 
168 // Include implementation of templated functions.
169 #include "furthest_neighbor_sort_impl.hpp"
170 
171 #endif