MLPACK  1.0.10
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
static double BestDistance()
Return what should represent the best 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 shoul...
static double BestNodeToNodeDistance(const TreeType *queryNode, const TreeType *referenceNode)
Return the best possible distance between two nodes.
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 CombineBest(const double a, const double b)
Return the best combination of the two distances.
This class implements the necessary methods for the SortPolicy template parameter of the NeighborSear...
static double CombineWorst(const double a, const double b)
Return the worst combination of the two distances.
static double WorstDistance()
Return what should represent the worst possible distance with this particular sort policy...