SYNOPSIS

Public Member Functions

RangeSearch (const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const bool naive=false, const bool singleMode=false, const MetricType metric=MetricType())

Initialize the RangeSearch object with a different reference set and a query set. RangeSearch (const typename TreeType::Mat &referenceSet, const bool naive=false, const bool singleMode=false, const MetricType metric=MetricType())

Initialize the RangeSearch object with only a reference set, which will also be used as a query set. RangeSearch (TreeType *referenceTree, TreeType *queryTree, const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const bool singleMode=false, const MetricType metric=MetricType())

Initialize the RangeSearch object with the given datasets and pre-constructed trees. RangeSearch (TreeType *referenceTree, const typename TreeType::Mat &referenceSet, const bool singleMode=false, const MetricType metric=MetricType())

Initialize the RangeSearch object with the given reference dataset and pre-constructed tree. ~RangeSearch ()

Destroy the RangeSearch object. 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 objects. std::string ToString () const

Private Attributes

bool hasQuerySet

If true, a query set was passed; if false, the query set is the reference set. MetricType metric

Instantiated distance metric. bool naive

If true, O(n^2) naive computation is used. size_t numPrunes

The number of pruned nodes during computation. std::vector< size_t > oldFromNewQueries

Mappings to old query indices (used when this object builds trees). std::vector< size_t > oldFromNewReferences

Mappings to old reference indices (used when this object builds trees). TreeType::Mat queryCopy

Copy of query matrix; used when a tree is built internally. const TreeType::Mat & querySet

Query set (data should be accessed using this). TreeType * queryTree

Query tree (may be NULL). TreeType::Mat referenceCopy

Copy of reference matrix; used when a tree is built internally. const TreeType::Mat & referenceSet

Reference set (data should be accessed using this). TreeType * referenceTree

Reference tree. bool singleMode

If true, single-tree computation is used. bool treeOwner

If true, this object is responsible for deleting the trees.

Detailed Description

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>>class mlpack::range::RangeSearch< MetricType, TreeType >

The RangeSearch class is a template class for performing range searches.

It is implemented in the style of a generalized tree-independent dual-tree algorithm; for more details on the actual algorithm, see the RangeSearchRules class.

Definition at line 43 of file range_search.hpp.

Constructor & Destructor Documentation

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::\fBRangeSearch\fP (const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const boolnaive = \fCfalse\fP, const boolsingleMode = \fCfalse\fP, const MetricTypemetric = \fCMetricType()\fP)

Initialize the RangeSearch object with a different reference set and a query set. Optionally, perform the computation in naive mode or single-tree mode, and set the leaf size used for tree-building. Additionally, an instantiated metric can be given, for cases where the distance metric holds data.

This method will copy the matrices to internal copies, which are rearranged during tree-building. You can avoid this extra copy by pre-constructing the trees and passing them using a different constructor.

Parameters:

referenceSet Reference dataset.

querySet Query dataset.

naive Whether the computation should be done in O(n^2) naive mode.

singleMode Whether single-tree computation should be used (as opposed to dual-tree computation).

leafSize The leaf size to be used during tree construction.

metric Instantiated distance metric.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::\fBRangeSearch\fP (const typename TreeType::Mat &referenceSet, const boolnaive = \fCfalse\fP, const boolsingleMode = \fCfalse\fP, const MetricTypemetric = \fCMetricType()\fP)

Initialize the RangeSearch object with only a reference set, which will also be used as a query set. Optionally, perform the computation in naive mode or single-tree mode, and set the leaf size used for tree-building. Additionally an instantiated metric can be given, for cases where the distance metric holds data.

This method will copy the reference matrix to an internal copy, which is rearranged during tree-building. You can avoid this extra copy by pre-constructing the reference tree and passing it using a different constructor.

Parameters:

referenceSet Reference dataset.

naive Whether the computation should be done in O(n^2) naive mode.

singleMode Whether single-tree computation should be used (as opposed to dual-tree computation).

leafSize The leaf size to be used during tree construction.

metric Instantiated distance metric.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::\fBRangeSearch\fP (TreeType *referenceTree, TreeType *queryTree, const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const boolsingleMode = \fCfalse\fP, const MetricTypemetric = \fCMetricType()\fP)

Initialize the RangeSearch object with the given datasets and pre-constructed trees. It is assumed that the points in referenceSet and querySet correspond to the points in referenceTree and queryTree, respectively. Optionally, choose to use single-tree mode. Naive mode is not available as an option for this constructor; instead, to run naive computation, construct a tree with all the points in one leaf (i.e. leafSize = number of points). Additionally, an instantiated distance metric can be given, for cases where the distance metric holds data.

There is no copying of the data matrices in this constructor (because tree-building is not necessary), so this is the constructor to use when copies absolutely must be avoided.

Note:

Because tree-building (at least with BinarySpaceTree) modifies the ordering of a matrix, be sure you pass the modified matrix to this object! In addition, mapping the points of the matrix back to their original indices is not done when this constructor is used.

Parameters:

referenceTree Pre-built tree for reference points.

queryTree Pre-built tree for query points.

referenceSet Set of reference points corresponding to referenceTree.

querySet Set of query points corresponding to queryTree.

singleMode Whether single-tree computation should be used (as opposed to dual-tree computation).

metric Instantiated distance metric.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::\fBRangeSearch\fP (TreeType *referenceTree, const typename TreeType::Mat &referenceSet, const boolsingleMode = \fCfalse\fP, const MetricTypemetric = \fCMetricType()\fP)

Initialize the RangeSearch object with the given reference dataset and pre-constructed tree. It is assumed that the points in referenceSet correspond to the points in referenceTree. Optionally, choose to use single-tree mode. Naive mode is not available as an option for this constructor; instead, to run naive computation, construct a tree with all the points in one leaf (i.e. leafSize = number of points). Additionally, an instantiated distance metric can be given, for the case where the distance metric holds data.

There is no copying of the data matrices in this constructor (because tree-building is not necessary), so this is the constructor to use when copies absolutely must be avoided.

Note:

Because tree-building (at least with BinarySpaceTree) modifies the ordering of a matrix, be sure you pass the modified matrix to this object! In addition, mapping the points of the matrix back to their original indices is not done when this constructor is used.

Parameters:

referenceTree Pre-built tree for reference points.

referenceSet Set of reference points corresponding to referenceTree.

singleMode Whether single-tree computation should be used (as opposed to dual-tree computation).

metric Instantiated distance metric.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::~\fBRangeSearch\fP ()

Destroy the RangeSearch object. If trees were created, they will be deleted.

Member Function Documentation

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> void \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::Search (const \fBmath::Range\fP &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 objects. Each entry in the external vector corresponds to a query point. Each of these entries holds a vector which contains the indices and distances of the reference points falling into the given range.

That is:

  • neighbors.size() and distances.size() both equal the number of query points.

  • neighbors[i] contains the indices of all the points in the reference set which have distances inside the given range to query point i.

  • distances[i] contains all of the distances corresponding to the indices contained in neighbors[i].

  • neighbors[i] and distances[i] are not sorted in any particular order.

Parameters:

range Range of distances in which to search.

neighbors Object which will hold the list of neighbors for each point which fell into the given range, for each query point.

distances Object which will hold the list of distances for each point which fell into the given range, for each query point.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> std::string \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::ToString () const

Member Data Documentation

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> bool \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::hasQuerySet\fC [private]\fP

If true, a query set was passed; if false, the query set is the reference set.

Definition at line 227 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> MetricType \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::metric\fC [private]\fP

Instantiated distance metric.

Definition at line 235 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> bool \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::naive\fC [private]\fP

If true, O(n^2) naive computation is used.

Definition at line 230 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> size_t \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::numPrunes\fC [private]\fP

The number of pruned nodes during computation.

Definition at line 238 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> std::vector<size_t> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::oldFromNewQueries\fC [private]\fP

Mappings to old query indices (used when this object builds trees).

Definition at line 221 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> std::vector<size_t> \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::oldFromNewReferences\fC [private]\fP

Mappings to old reference indices (used when this object builds trees).

Definition at line 219 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> TreeType::Mat \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::queryCopy\fC [private]\fP

Copy of query matrix; used when a tree is built internally.

Definition at line 206 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> const TreeType::Mat& \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::querySet\fC [private]\fP

Query set (data should be accessed using this).

Definition at line 211 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> TreeType* \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::queryTree\fC [private]\fP

Query tree (may be NULL).

Definition at line 216 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> TreeType::Mat \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::referenceCopy\fC [private]\fP

Copy of reference matrix; used when a tree is built internally.

Definition at line 204 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> const TreeType::Mat& \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::referenceSet\fC [private]\fP

Reference set (data should be accessed using this).

Definition at line 209 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> TreeType* \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::referenceTree\fC [private]\fP

Reference tree.

Definition at line 214 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> bool \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::singleMode\fC [private]\fP

If true, single-tree computation is used.

Definition at line 232 of file range_search.hpp.

template<typename MetricType = mlpack::metric::EuclideanDistance, typename TreeType = tree::BinarySpaceTree<bound::HRectBound<2>, RangeSearchStat>> bool \fBmlpack::range::RangeSearch\fP< MetricType, TreeType >::treeOwner\fC [private]\fP

If true, this object is responsible for deleting the trees.

Definition at line 224 of file range_search.hpp.

Author

Generated automatically by Doxygen for MLPACK from the source code.