mlpack  1.0.12
furthest_neighbor_sort.hpp
Go to the documentation of this file.
1 
15 #ifndef __MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_HPP
16 #define __MLPACK_METHODS_NEIGHBOR_SEARCH_FURTHEST_NEIGHBOR_SORT_HPP
17 
18 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace neighbor {
22 
30 {
31  public:
46  static size_t SortDistance(const arma::vec& list,
47  const arma::Col<size_t>& indices,
48  double newDistance);
49 
59  static inline bool IsBetter(const double value, const double ref)
60  {
61  return (value > ref);
62  }
63 
69  template<typename TreeType>
70  static double BestNodeToNodeDistance(const TreeType* queryNode,
71  const TreeType* referenceNode);
72 
79  template<typename TreeType>
80  static double BestNodeToNodeDistance(const TreeType* queryNode,
81  const TreeType* referenceNode,
82  const double centerToCenterDistance);
83 
96  template<typename TreeType>
97  static double BestNodeToNodeDistance(const TreeType* queryNode,
98  const TreeType* referenceNode,
99  const TreeType* referenceChildNode,
100  const double centerToCenterDistance);
101 
107  template<typename VecType, typename TreeType>
108  static double BestPointToNodeDistance(const VecType& queryPoint,
109  const TreeType* referenceNode);
110 
117  template<typename VecType, typename TreeType>
118  static double BestPointToNodeDistance(const VecType& queryPoint,
119  const TreeType* referenceNode,
120  const double pointToCenterDistance);
121 
129  static inline double WorstDistance() { return 0; }
130 
138  static inline double BestDistance() { return DBL_MAX; }
139 
143  static inline double CombineBest(const double a, const double b)
144  {
145  if (a == DBL_MAX || b == DBL_MAX)
146  return DBL_MAX;
147  return a + b;
148  }
149 
153  static inline double CombineWorst(const double a, const double b)
154  { return std::max(a - b, 0.0); }
155 };
156 
157 }; // namespace neighbor
158 }; // namespace mlpack
159 
160 // Include implementation of templated functions.
161 #include "furthest_neighbor_sort_impl.hpp"
162 
163 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: load.hpp:23
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...