MLPACK  1.0.7
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
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.
static bool IsBetter(const double value, const double ref)
Return whether or not value is &quot;better&quot; than ref.
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 size_t SortDistance(const arma::vec &list, double newDistance)
Return the index in the vector where the new distance should be inserted, or size_t() - 1 if it shoul...
static double WorstDistance()
Return what should represent the worst possible distance with this particular sort policy...
static double BestPointToNodeDistance(const arma::vec &queryPoint, const TreeType *referenceNode)
Return the best possible distance between a node and a point.