MLPACK  1.0.8
range_search.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP
24 #define __MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_HPP
25 
26 #include <mlpack/core.hpp>
27 
29 
31 
32 #include "range_search_stat.hpp"
33 
34 namespace mlpack {
35 namespace range {
36 
43 template<typename MetricType = mlpack::metric::EuclideanDistance,
47 {
48  public:
68  RangeSearch(const typename TreeType::Mat& referenceSet,
69  const typename TreeType::Mat& querySet,
70  const bool naive = false,
71  const bool singleMode = false,
72  const size_t leafSize = 20,
73  const MetricType metric = MetricType());
74 
94  RangeSearch(const typename TreeType::Mat& referenceSet,
95  const bool naive = false,
96  const bool singleMode = false,
97  const size_t leafSize = 20,
98  const MetricType metric = MetricType());
99 
129  RangeSearch(TreeType* referenceTree,
130  TreeType* queryTree,
131  const typename TreeType::Mat& referenceSet,
132  const typename TreeType::Mat& querySet,
133  const bool singleMode = false,
134  const MetricType metric = MetricType());
135 
163  RangeSearch(TreeType* referenceTree,
164  const typename TreeType::Mat& referenceSet,
165  const bool singleMode = false,
166  const MetricType metric = MetricType());
167 
172  ~RangeSearch();
173 
200  void Search(const math::Range& range,
201  std::vector<std::vector<size_t> >& neighbors,
202  std::vector<std::vector<double> >& distances);
203 
204  private:
206  typename TreeType::Mat referenceCopy;
208  typename TreeType::Mat queryCopy;
209 
211  const typename TreeType::Mat& referenceSet;
213  const typename TreeType::Mat& querySet;
214 
216  TreeType* referenceTree;
218  TreeType* queryTree;
219 
221  std::vector<size_t> oldFromNewReferences;
223  std::vector<size_t> oldFromNewQueries;
224 
226  bool treeOwner;
230 
232  bool naive;
235 
237  MetricType metric;
238 
240  size_t numPrunes;
241 };
242 
243 }; // namespace range
244 }; // namespace mlpack
245 
246 // Include implementation.
247 #include "range_search_impl.hpp"
248 
249 #endif
The RangeSearch class is a template class for performing range searches.
LMetric< 2, true > EuclideanDistance
Definition: lmetric.hpp:104
~RangeSearch()
Destroy the RangeSearch object.
std::vector< size_t > oldFromNewReferences
Mappings to old reference indices (used when this object builds trees).
size_t numPrunes
The number of pruned nodes during computation.
A binary space partitioning tree, such as a KD-tree or a ball tree.
bool naive
If true, O(n^2) naive computation is used.
TreeType * referenceTree
Reference tree.
void Search(const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances)
Search for all points in the given range, returning the results in the neighbors and distances object...
TreeType::Mat referenceCopy
Copy of reference matrix; used when a tree is built internally.
Statistic class for RangeSearch, to be set to the StatisticType of the tree type that range search is...
TreeType::Mat queryCopy
Copy of query matrix; used when a tree is built internally.
bool hasQuerySet
If true, a query set was passed; if false, the query set is the reference set.
const TreeType::Mat & referenceSet
Reference set (data should be accessed using this).
std::vector< size_t > oldFromNewQueries
Mappings to old query indices (used when this object builds trees).
const TreeType::Mat & querySet
Query set (data should be accessed using this).
TreeType * queryTree
Query tree (may be NULL).
MetricType metric
Instantiated distance metric.
bool treeOwner
If true, this object is responsible for deleting the trees.
bool singleMode
If true, single-tree computation is used.
Simple real-valued range.
Definition: range.hpp:31
RangeSearch(const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const bool naive=false, const bool singleMode=false, const size_t leafSize=20, const MetricType metric=MetricType())
Initialize the RangeSearch object with a different reference set and a query set. ...