mlpack  master
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
mlpack::range::RangeSearchRules< MetricType, TreeType > Class Template Reference

The RangeSearchRules class is a template helper class used by RangeSearch class when performing range searches. More...

Public Types

typedef tree::TraversalInfo< TreeType > TraversalInfoType
 

Public Member Functions

 RangeSearchRules (const arma::mat &referenceSet, const arma::mat &querySet, const math::Range &range, std::vector< std::vector< size_t > > &neighbors, std::vector< std::vector< double > > &distances, MetricType &metric, const bool sameSet=false)
 Construct the RangeSearchRules object. More...
 
double BaseCase (const size_t queryIndex, const size_t referenceIndex)
 Compute the base case between the given query point and reference point. More...
 
size_t BaseCases () const
 Get the number of base cases. More...
 
double Rescore (const size_t queryIndex, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
double Rescore (TreeType &queryNode, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
double Score (const size_t queryIndex, TreeType &referenceNode)
 Get the score for recursion order. More...
 
double Score (TreeType &queryNode, TreeType &referenceNode)
 Get the score for recursion order. More...
 
size_t Scores () const
 Get the number of scores (that is, calls to RangeDistance()). More...
 
const TraversalInfoTypeTraversalInfo () const
 
TraversalInfoTypeTraversalInfo ()
 

Private Member Functions

void AddResult (const size_t queryIndex, TreeType &referenceNode)
 Add all the points in the given node to the results for the given query point. More...
 

Private Attributes

size_t baseCases
 The number of base cases. More...
 
std::vector< std::vector< double > > & distances
 The vector the resultant neighbor distances should be stored in. More...
 
size_t lastQueryIndex
 The last query index. More...
 
size_t lastReferenceIndex
 The last reference index. More...
 
MetricType & metric
 The instantiated metric. More...
 
std::vector< std::vector< size_t > > & neighbors
 The vector the resultant neighbor indices should be stored in. More...
 
const arma::mat & querySet
 The query set. More...
 
const math::Rangerange
 The range of distances for which we are searching. More...
 
const arma::mat & referenceSet
 The reference set. More...
 
bool sameSet
 If true, the query and reference set are taken to be the same. More...
 
size_t scores
 THe number of scores. More...
 
TraversalInfoType traversalInfo
 

Detailed Description

template<typename MetricType, typename TreeType>
class mlpack::range::RangeSearchRules< MetricType, TreeType >

The RangeSearchRules class is a template helper class used by RangeSearch class when performing range searches.

Template Parameters
MetricTypeThe metric to use for computation.
TreeTypeThe tree type to use; must adhere to the TreeType API.

Definition at line 28 of file range_search_rules.hpp.

Member Typedef Documentation

template<typename MetricType , typename TreeType >
typedef tree::TraversalInfo<TreeType> mlpack::range::RangeSearchRules< MetricType, TreeType >::TraversalInfoType

Definition at line 110 of file range_search_rules.hpp.

Constructor & Destructor Documentation

template<typename MetricType , typename TreeType >
mlpack::range::RangeSearchRules< MetricType, TreeType >::RangeSearchRules ( const arma::mat &  referenceSet,
const arma::mat &  querySet,
const math::Range range,
std::vector< std::vector< size_t > > &  neighbors,
std::vector< std::vector< double > > &  distances,
MetricType &  metric,
const bool  sameSet = false 
)

Construct the RangeSearchRules object.

This is usually done from within the RangeSearch class at search time.

Parameters
referenceSetSet of reference data.
querySetSet of query data.
rangeRange to search for.
neighborsVector to store resulting neighbors in.
distancesVector to store resulting distances in.
metricInstantiated metric.
sameSetIf true, the query and reference set are taken to be the same, and a query point will not return itself in the results.

Member Function Documentation

template<typename MetricType , typename TreeType >
void mlpack::range::RangeSearchRules< MetricType, TreeType >::AddResult ( const size_t  queryIndex,
TreeType &  referenceNode 
)
private

Add all the points in the given node to the results for the given query point.

If the base case has already been calculated, we make sure to not add that to the results twice.

template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::BaseCase ( const size_t  queryIndex,
const size_t  referenceIndex 
)

Compute the base case between the given query point and reference point.

Parameters
queryIndexIndex of query point.
referenceIndexIndex of reference point.
template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::BaseCases ( ) const
inline

Get the number of base cases.

Definition at line 116 of file range_search_rules.hpp.

References mlpack::range::RangeSearchRules< MetricType, TreeType >::baseCases.

template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::Rescore ( const size_t  queryIndex,
TreeType &  referenceNode,
const double  oldScore 
) const

Re-evaluate the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned). This is used when the score has already been calculated, but another recursion may have modified the bounds for pruning. So the old score is checked against the new pruning bound.

Parameters
queryIndexIndex of query point.
referenceNodeCandidate node to be recursed into.
oldScoreOld score produced by Score() (or Rescore()).
template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::Rescore ( TreeType &  queryNode,
TreeType &  referenceNode,
const double  oldScore 
) const

Re-evaluate the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned). This is used when the score has already been calculated, but another recursion may have modified the bounds for pruning. So the old score is checked against the new pruning bound.

Parameters
queryNodeCandidate query node to recurse into.
referenceNodeCandidate reference node to recurse into.
oldScoreOld score produced by Score() (or Rescore()).
template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::Score ( const size_t  queryIndex,
TreeType &  referenceNode 
)

Get the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned).

Parameters
queryIndexIndex of query point.
referenceNodeCandidate node to be recursed into.
template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::Score ( TreeType &  queryNode,
TreeType &  referenceNode 
)

Get the score for recursion order.

A low score indicates priority for recursion, while DBL_MAX indicates that the node should not be recursed into at all (it should be pruned).

Parameters
queryNodeCandidate query node to recurse into.
referenceNodeCandidate reference node to recurse into.
template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::Scores ( ) const
inline

Get the number of scores (that is, calls to RangeDistance()).

Definition at line 118 of file range_search_rules.hpp.

References mlpack::range::RangeSearchRules< MetricType, TreeType >::scores.

template<typename MetricType , typename TreeType >
const TraversalInfoType& mlpack::range::RangeSearchRules< MetricType, TreeType >::TraversalInfo ( ) const
inline
template<typename MetricType , typename TreeType >
TraversalInfoType& mlpack::range::RangeSearchRules< MetricType, TreeType >::TraversalInfo ( )
inline

Member Data Documentation

template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::baseCases
private

The number of base cases.

Definition at line 156 of file range_search_rules.hpp.

Referenced by mlpack::range::RangeSearchRules< MetricType, TreeType >::BaseCases().

template<typename MetricType , typename TreeType >
std::vector<std::vector<double> >& mlpack::range::RangeSearchRules< MetricType, TreeType >::distances
private

The vector the resultant neighbor distances should be stored in.

Definition at line 134 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::lastQueryIndex
private

The last query index.

Definition at line 143 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::lastReferenceIndex
private

The last reference index.

Definition at line 145 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
MetricType& mlpack::range::RangeSearchRules< MetricType, TreeType >::metric
private

The instantiated metric.

Definition at line 137 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
std::vector<std::vector<size_t> >& mlpack::range::RangeSearchRules< MetricType, TreeType >::neighbors
private

The vector the resultant neighbor indices should be stored in.

Definition at line 131 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
const arma::mat& mlpack::range::RangeSearchRules< MetricType, TreeType >::querySet
private

The query set.

Definition at line 125 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
const math::Range& mlpack::range::RangeSearchRules< MetricType, TreeType >::range
private

The range of distances for which we are searching.

Definition at line 128 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
const arma::mat& mlpack::range::RangeSearchRules< MetricType, TreeType >::referenceSet
private

The reference set.

Definition at line 122 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
bool mlpack::range::RangeSearchRules< MetricType, TreeType >::sameSet
private

If true, the query and reference set are taken to be the same.

Definition at line 140 of file range_search_rules.hpp.

template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::scores
private

THe number of scores.

Definition at line 158 of file range_search_rules.hpp.

Referenced by mlpack::range::RangeSearchRules< MetricType, TreeType >::Scores().

template<typename MetricType , typename TreeType >
TraversalInfoType mlpack::range::RangeSearchRules< MetricType, TreeType >::traversalInfo
private

The documentation for this class was generated from the following file: