mlpack
3.0.0

The RangeSearch class is a template class for performing range searches. More...
Public Types  
typedef TreeType< MetricType, RangeSearchStat, MatType >  Tree 
Convenience typedef. More...  
Public Member Functions  
RangeSearch (MatType referenceSet, const bool naive=false, const bool singleMode=false, const MetricType metric=MetricType())  
Initialize the RangeSearch object with a given reference dataset (this is the dataset which is searched). More...  
RangeSearch (Tree *referenceTree, const bool singleMode=false, const MetricType metric=MetricType())  
Initialize the RangeSearch object with the given preconstructed reference tree (this is the tree built on the reference set, which is the set that is searched). More...  
RangeSearch (const bool naive=false, const bool singleMode=false, const MetricType metric=MetricType())  
Initialize the RangeSearch object without any reference data. More...  
RangeSearch (const RangeSearch &other)  
Construct the RangeSearch model as a copy of the given model. More...  
RangeSearch (RangeSearch &&other)  
Construct the RangeSearch model by taking ownership of the given model. More...  
~RangeSearch ()  
Destroy the RangeSearch object. More...  
size_t  BaseCases () const 
Get the number of base cases during the last search. More...  
bool  Naive () const 
Get whether naive search is being used. More...  
bool &  Naive () 
Modify whether naive search is being used. More...  
RangeSearch &  operator= (RangeSearch other) 
Copy the given RangeSearch model. More...  
const MatType &  ReferenceSet () const 
Return the reference set. More...  
Tree *  ReferenceTree () 
Return the reference tree (or NULL if in naive mode). More...  
size_t  Scores () const 
Get the number of scores during the last search. More...  
void  Search (const MatType &querySet, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances) 
Search for all reference points in the given range for each point in the query set, returning the results in the neighbors and distances objects. More...  
void  Search (Tree *queryTree, const math::Range &range, std::vector< std::vector< size_t >> &neighbors, std::vector< std::vector< double >> &distances) 
Given a prebuilt query tree, search for all reference points in the given range for each point in the query set, returning the results in the neighbors and distances objects. More...  
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 for each point in the reference set (which was passed to the constructor), returning the results in the neighbors and distances objects. More...  
template < typename Archive >  
void  serialize (Archive &ar, const unsigned int version) 
Serialize the model. More...  
bool  SingleMode () const 
Get whether singletree search is being used. More...  
bool &  SingleMode () 
Modify whether singletree search is being used. More...  
void  Train (MatType referenceSet) 
Set the reference set to a new reference set, and build a tree if necessary. More...  
void  Train (Tree *referenceTree) 
Set the reference tree to a new reference tree. More...  
Detailed Description
template<typenameMetricType=metric::EuclideanDistance,typenameMatType=arma::mat,template<typenameTreeMetricType,typenameTreeStatType,typenameTreeMatType>classTreeType=tree::KDTree>
class mlpack::range::RangeSearch< MetricType, MatType, TreeType >
The RangeSearch class is a template class for performing range searches.
It is implemented in the style of a generalized treeindependent dualtree algorithm; for more details on the actual algorithm, see the RangeSearchRules class.
 Template Parameters

MetricType Metric to use for range search calculations. MatType Type of data to use. TreeType Type of tree to use; must satisfy the TreeType policy API.
Definition at line 42 of file range_search.hpp.
Member Typedef Documentation
◆ Tree
typedef TreeType<MetricType, RangeSearchStat, MatType> Tree 
Convenience typedef.
Definition at line 46 of file range_search.hpp.
Constructor & Destructor Documentation
◆ RangeSearch() [1/5]
RangeSearch  (  MatType  referenceSet, 
const bool  naive = false , 

const bool  singleMode = false , 

const MetricType  metric = MetricType() 

) 
Initialize the RangeSearch object with a given reference dataset (this is the dataset which is searched).
Optionally, perform the computation in naive mode or singletree mode. Additionally, an instantiated metric can be given, for cases where the distance metric holds data.
This method will move the matrices to internal copies, which are rearranged during treebuilding. You can avoid creating an extra copy by preconstructing the trees and passing them in using std::move.
 Parameters

referenceSet Reference dataset. naive Whether the computation should be done in O(n^2) naive mode. singleMode Whether singletree computation should be used (as opposed to dualtree computation). metric Instantiated distance metric.
◆ RangeSearch() [2/5]
RangeSearch  (  Tree *  referenceTree, 
const bool  singleMode = false , 

const MetricType  metric = MetricType() 

) 
Initialize the RangeSearch object with the given preconstructed reference tree (this is the tree built on the reference set, which is the set that is searched).
Optionally, choose to use singletree mode, which will not build a tree on query points. Naive mode is not available as an option for this constructor. 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 treebuilding is not necessary), so this is the constructor to use when copies absolutely must be avoided.
 Note
 Because treebuilding (at least with BinarySpaceTree) modifies the ordering of a matrix, be aware that mapping of the points back to their original indices is not done when this constructor is used.
 Parameters

referenceTree Prebuilt tree for reference points. referenceSet Set of reference points corresponding to referenceTree. singleMode Whether singletree computation should be used (as opposed to dualtree computation). metric Instantiated distance metric.
◆ RangeSearch() [3/5]
RangeSearch  (  const bool  naive = false , 
const bool  singleMode = false , 

const MetricType  metric = MetricType() 

) 
Initialize the RangeSearch object without any reference data.
If the monochromatic Search() is called before a reference set is set with Train(), no results will be returned (since the reference set is empty).
 Parameters

naive Whether to use naive search. singleMode Whether singletree computation should be used (as opposed to dualtree computation). metric Instantiated metric.
◆ RangeSearch() [4/5]
RangeSearch  (  const RangeSearch< MetricType, MatType, TreeType > &  other  ) 
Construct the RangeSearch model as a copy of the given model.
Note that this may be computationally intensive!
 Parameters

other RangeSearch model to copy.
◆ RangeSearch() [5/5]
RangeSearch  (  RangeSearch< MetricType, MatType, TreeType > &&  other  ) 
Construct the RangeSearch model by taking ownership of the given model.
 Parameters

other RangeSearch model to take ownership of.
◆ ~RangeSearch()
~RangeSearch  (  ) 
Destroy the RangeSearch object.
If trees were created, they will be deleted.
Member Function Documentation
◆ BaseCases()

inline 
Get the number of base cases during the last search.
Definition at line 276 of file range_search.hpp.
◆ Naive() [1/2]

inline 
Get whether naive search is being used.
Definition at line 271 of file range_search.hpp.
◆ Naive() [2/2]

inline 
Modify whether naive search is being used.
Definition at line 273 of file range_search.hpp.
◆ operator=()
RangeSearch& operator=  (  RangeSearch< MetricType, MatType, TreeType >  other  ) 
Copy the given RangeSearch model.
Use std::move to pass in the model if the old copy is no longer needed.
 Parameters

other RangeSearch model to copy.
◆ ReferenceSet()

inline 
Return the reference set.
Definition at line 285 of file range_search.hpp.
◆ ReferenceTree()

inline 
Return the reference tree (or NULL if in naive mode).
Definition at line 288 of file range_search.hpp.
◆ Scores()

inline 
Get the number of scores during the last search.
Definition at line 278 of file range_search.hpp.
References RangeSearch< MetricType, MatType, TreeType >::serialize().
◆ Search() [1/3]
void Search  (  const MatType &  querySet, 
const math::Range &  range,  
std::vector< std::vector< size_t >> &  neighbors,  
std::vector< std::vector< double >> &  distances  
) 
Search for all reference points in the given range for each point in the query set, 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

querySet Set of query points to search with. 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.
◆ Search() [2/3]
void Search  (  Tree *  queryTree, 
const math::Range &  range,  
std::vector< std::vector< size_t >> &  neighbors,  
std::vector< std::vector< double >> &  distances  
) 
Given a prebuilt query tree, search for all reference points in the given range for each point in the query set, 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.
If either naive or singleMode are set to true, this will throw an invalid_argument exception; passing in a query tree implies dualtree search.
If you want to use the reference tree as the query tree, instead call the overload of Search() that does not take a query set.
 Parameters

queryTree Tree built on query points. 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.
◆ Search() [3/3]
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 for each point in the reference set (which was passed to the constructor), returning the results in the neighbors and distances objects.
This means that the query set and the reference set are the same.
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

queryTree Tree built on query points. 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.
◆ serialize()
void serialize  (  Archive &  ar, 
const unsigned int  version  
) 
Serialize the model.
Referenced by RangeSearch< MetricType, MatType, TreeType >::Scores().
◆ SingleMode() [1/2]

inline 
Get whether singletree search is being used.
Definition at line 266 of file range_search.hpp.
◆ SingleMode() [2/2]

inline 
Modify whether singletree search is being used.
Definition at line 268 of file range_search.hpp.
◆ Train() [1/2]
void Train  (  MatType  referenceSet  ) 
Set the reference set to a new reference set, and build a tree if necessary.
This method is called 'Train()' in order to match the rest of the mlpack abstractions, even though calling this "training" is maybe a bit of a stretch.
Use std::move to pass in the reference set if the old copy is no longer needed.
 Parameters

referenceSet New set of reference data.
◆ Train() [2/2]
void Train  (  Tree *  referenceTree  ) 
Set the reference tree to a new reference tree.
The documentation for this class was generated from the following file:
 src/mlpack/methods/range_search/range_search.hpp
Generated by 1.8.13