nearest_neighbor_sort.hpp
Go to the documentation of this file.00001
00023 #ifndef __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
00024 #define __MLPACK_METHODS_NEIGHBOR_SEARCH_NEAREST_NEIGHBOR_SORT_HPP
00025
00026 #include <mlpack/core.hpp>
00027
00028 namespace mlpack {
00029 namespace neighbor {
00030
00041 class NearestNeighborSort
00042 {
00043 public:
00058 static size_t SortDistance(const arma::vec& list, double newDistance);
00059
00069 static inline bool IsBetter(const double value, const double ref)
00070 {
00071 return (value < ref);
00072 }
00073
00079 template<typename TreeType>
00080 static double BestNodeToNodeDistance(const TreeType* queryNode,
00081 const TreeType* referenceNode);
00082
00089 template<typename TreeType>
00090 static double BestNodeToNodeDistance(const TreeType* queryNode,
00091 const TreeType* referenceNode,
00092 const double centerToCenterDistance);
00093
00106 template<typename TreeType>
00107 static double BestNodeToNodeDistance(const TreeType* queryNode,
00108 const TreeType* referenceNode,
00109 const TreeType* referenceChildNode,
00110 const double centerToCenterDistance);
00116 template<typename TreeType>
00117 static double BestPointToNodeDistance(const arma::vec& queryPoint,
00118 const TreeType* referenceNode);
00119
00126 template<typename TreeType>
00127 static double BestPointToNodeDistance(const arma::vec& queryPoint,
00128 const TreeType* referenceNode,
00129 const double pointToCenterDistance);
00130
00138 static inline double WorstDistance() { return DBL_MAX; }
00139
00147 static inline double BestDistance() { return 0.0; }
00148
00152 static inline double CombineBest(const double a, const double b)
00153 {
00154 return std::max(a - b, 0.0);
00155 }
00156
00160 static inline double CombineWorst(const double a, const double b)
00161 {
00162 if (a == DBL_MAX || b == DBL_MAX)
00163 return DBL_MAX;
00164 return a + b;
00165 }
00166 };
00167
00168 };
00169 };
00170
00171
00172 #include "nearest_neighbor_sort_impl.hpp"
00173
00174 #endif