MLPACK  1.0.10
ra_search.hpp
Go to the documentation of this file.
1 
33 #ifndef __MLPACK_METHODS_RANN_RA_SEARCH_HPP
34 #define __MLPACK_METHODS_RANN_RA_SEARCH_HPP
35 
36 #include <mlpack/core.hpp>
37 
39 
42 
43 #include "ra_query_stat.hpp"
44 
67 template<typename SortPolicy = NearestNeighborSort,
68  typename MetricType = mlpack::metric::SquaredEuclideanDistance,
69  typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2, false>,
70  RAQueryStat<SortPolicy> > >
71 class RASearch
72 {
73  public:
95  RASearch(const typename TreeType::Mat& referenceSet,
96  const typename TreeType::Mat& querySet,
97  const bool naive = false,
98  const bool singleMode = false,
99  const MetricType metric = MetricType());
100 
123  RASearch(const typename TreeType::Mat& referenceSet,
124  const bool naive = false,
125  const bool singleMode = false,
126  const MetricType metric = MetricType());
127 
157  RASearch(TreeType* referenceTree,
158  TreeType* queryTree,
159  const typename TreeType::Mat& referenceSet,
160  const typename TreeType::Mat& querySet,
161  const bool singleMode = false,
162  const MetricType metric = MetricType());
163 
191  RASearch(TreeType* referenceTree,
192  const typename TreeType::Mat& referenceSet,
193  const bool singleMode = false,
194  const MetricType metric = MetricType());
195 
200  ~RASearch();
201 
238  void Search(const size_t k,
239  arma::Mat<size_t>& resultingNeighbors,
240  arma::mat& distances,
241  const double tau = 5,
242  const double alpha = 0.95,
243  const bool sampleAtLeaves = false,
244  const bool firstLeafExact = false,
245  const size_t singleSampleLimit = 20);
246 
254  void ResetQueryTree();
255 
256  // Returns a string representation of this object.
257  std::string ToString() const;
258 
259  private:
262  arma::mat referenceCopy;
264  arma::mat queryCopy;
265 
267  const arma::mat& referenceSet;
269  const arma::mat& querySet;
270 
272  TreeType* referenceTree;
274  TreeType* queryTree;
275 
277  bool treeOwner;
280 
282  bool naive;
285 
287  MetricType metric;
288 
290  std::vector<size_t> oldFromNewReferences;
292  std::vector<size_t> oldFromNewQueries;
293 
296 
301  void ResetRAQueryStat(TreeType* treeNode);
302 }; // class RASearch
303 
304 }; // namespace neighbor
305 }; // namespace mlpack
306 
307 // Include implementation.
308 #include "ra_search_impl.hpp"
309 
310 // Include convenient typedefs.
311 #include "ra_typedef.hpp"
312 
313 #endif