mlpack  1.0.12
nearest_neighbor_sort.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
16 #define __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace neighbor {
22 
34 {
35  public:
50  static size_t SortDistance(const arma::vec& list,
51  const arma::Col<size_t>& indices,
52  double newDistance);
53 
63  static inline bool IsBetter(const double value, const double ref)
64  {
65  return (value < ref);
66  }
67 
73  template<typename TreeType>
74  static double BestNodeToNodeDistance(const TreeType* queryNode,
75  const TreeType* referenceNode);
76 
83  template<typename TreeType>
84  static double BestNodeToNodeDistance(const TreeType* queryNode,
85  const TreeType* referenceNode,
86  const double centerToCenterDistance);
87 
100  template<typename TreeType>
101  static double BestNodeToNodeDistance(const TreeType* queryNode,
102  const TreeType* referenceNode,
103  const TreeType* referenceChildNode,
104  const double centerToCenterDistance);
110  template<typename VecType, typename TreeType>
111  static double BestPointToNodeDistance(const VecType& queryPoint,
112  const TreeType* referenceNode);
113 
120  template<typename VecType, typename TreeType>
121  static double BestPointToNodeDistance(const VecType& queryPoint,
122  const TreeType* referenceNode,
123  const double pointToCenterDistance);
124 
132  static inline double WorstDistance() { return DBL_MAX; }
133 
141  static inline double BestDistance() { return 0.0; }
142 
146  static inline double CombineBest(const double a, const double b)
147  {
148  return std::max(a - b, 0.0);
149  }
150 
154  static inline double CombineWorst(const double a, const double b)
155  {
156  if (a == DBL_MAX || b == DBL_MAX)
157  return DBL_MAX;
158  return a + b;
159  }
160 };
161 
162 }; // namespace neighbor
163 }; // namespace mlpack
164 
165 // Include implementation of templated functions.
166 #include "nearest_neighbor_sort_impl.hpp"
167 
168 #endif
static double CombineWorst(const double a, const double b)
Return the worst combination of the two distances.
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
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.