range_search.hpp
Go to the documentation of this file.00001
00023 #ifndef __MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP
00024 #define __MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP
00025
00026 #include <mlpack/core.hpp>
00027
00028 #include <mlpack/core/metrics/lmetric.hpp>
00029
00030 #include <mlpack/core/tree/binary_space_tree.hpp>
00031
00032 #include "range_search_stat.hpp"
00033
00034 namespace mlpack {
00035 namespace range {
00036
00043 template<typename MetricType = mlpack::metric::EuclideanDistance,
00044 typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>,
00045 RangeSearchStat> >
00046 class RangeSearch
00047 {
00048 public:
00068 RangeSearch(const typename TreeType::Mat& referenceSet,
00069 const typename TreeType::Mat& querySet,
00070 const bool naive = false,
00071 const bool singleMode = false,
00072 const size_t leafSize = 20,
00073 const MetricType metric = MetricType());
00074
00094 RangeSearch(const typename TreeType::Mat& referenceSet,
00095 const bool naive = false,
00096 const bool singleMode = false,
00097 const size_t leafSize = 20,
00098 const MetricType metric = MetricType());
00099
00129 RangeSearch(TreeType* referenceTree,
00130 TreeType* queryTree,
00131 const typename TreeType::Mat& referenceSet,
00132 const typename TreeType::Mat& querySet,
00133 const bool singleMode = false,
00134 const MetricType metric = MetricType());
00135
00163 RangeSearch(TreeType* referenceTree,
00164 const typename TreeType::Mat& referenceSet,
00165 const bool singleMode = false,
00166 const MetricType metric = MetricType());
00167
00172 ~RangeSearch();
00173
00200 void Search(const math::Range& range,
00201 std::vector<std::vector<size_t> >& neighbors,
00202 std::vector<std::vector<double> >& distances);
00203
00204 private:
00206 typename TreeType::Mat referenceCopy;
00208 typename TreeType::Mat queryCopy;
00209
00211 const typename TreeType::Mat& referenceSet;
00213 const typename TreeType::Mat& querySet;
00214
00216 TreeType* referenceTree;
00218 TreeType* queryTree;
00219
00221 std::vector<size_t> oldFromNewReferences;
00223 std::vector<size_t> oldFromNewQueries;
00224
00226 bool treeOwner;
00229 bool hasQuerySet;
00230
00232 bool naive;
00234 bool singleMode;
00235
00237 MetricType metric;
00238
00240 size_t numPrunes;
00241 };
00242
00243 };
00244 };
00245
00246
00247 #include "range_search_impl.hpp"
00248
00249 #endif