MLPACK  1.0.8
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, double newDistance);
55 
65  static inline bool IsBetter(const double value, const double ref)
66  {
67  return (value > ref);
68  }
69 
75  template<typename TreeType>
76  static double BestNodeToNodeDistance(const TreeType* queryNode,
77  const TreeType* referenceNode);
78 
85  template<typename TreeType>
86  static double BestNodeToNodeDistance(const TreeType* queryNode,
87  const TreeType* referenceNode,
88  const double centerToCenterDistance);
89 
102  template<typename TreeType>
103  static double BestNodeToNodeDistance(const TreeType* queryNode,
104  const TreeType* referenceNode,
105  const TreeType* referenceChildNode,
106  const double centerToCenterDistance);
107 
113  template<typename TreeType>
114  static double BestPointToNodeDistance(const arma::vec& queryPoint,
115  const TreeType* referenceNode);
116 
123  template<typename TreeType>
124  static double BestPointToNodeDistance(const arma::vec& queryPoint,
125  const TreeType* referenceNode,
126  const double pointToCenterDistance);
127 
135  static inline double WorstDistance() { return 0; }
136 
144  static inline double BestDistance() { return DBL_MAX; }
145 
149  static inline double CombineBest(const double a, const double b)
150  {
151  if (a == DBL_MAX || b == DBL_MAX)
152  return DBL_MAX;
153  return a + b;
154  }
155 
159  static inline double CombineWorst(const double a, const double b)
160  { return std::max(a - b, 0.0); }
161 };
162 
163 }; // namespace neighbor
164 }; // namespace mlpack
165 
166 // Include implementation of templated functions.
167 #include "furthest_neighbor_sort_impl.hpp"
168 
169 #endif