mlpack
Public Types | Public Member Functions | 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...

#include <range_search_rules.hpp>

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...
 
double Score (const size_t queryIndex, TreeType &referenceNode)
 Get the score for recursion order. More...
 
double Rescore (const size_t queryIndex, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
double Score (TreeType &queryNode, TreeType &referenceNode)
 Get the score for recursion order. More...
 
double Rescore (TreeType &queryNode, TreeType &referenceNode, const double oldScore) const
 Re-evaluate the score for recursion order. More...
 
const TraversalInfoTypeTraversalInfo () const
 
TraversalInfoTypeTraversalInfo ()
 
size_t BaseCases () const
 Get the number of base cases.
 
size_t Scores () const
 Get the number of scores (that is, calls to RangeDistance()).
 
size_t MinimumBaseCases () const
 Get the minimum number of base cases we need to perform to have acceptable results. More...
 

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.

Constructor & Destructor Documentation

◆ RangeSearchRules()

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

◆ BaseCase()

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

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

The base case.

Parameters
queryIndexIndex of query point.
referenceIndexIndex of reference point.

Evaluate the distance between the two points and add to the results if necessary.

◆ MinimumBaseCases()

template<typename MetricType , typename TreeType >
size_t mlpack::range::RangeSearchRules< MetricType, TreeType >::MinimumBaseCases ( ) const
inline

Get the minimum number of base cases we need to perform to have acceptable results.

◆ Rescore() [1/2]

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.

Single-tree rescoring function.

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()).

◆ Rescore() [2/2]

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.

Dual-tree rescoring function.

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()).

◆ Score() [1/2]

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

Get the score for recursion order.

Single-tree scoring function.

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.

◆ Score() [2/2]

template<typename MetricType , typename TreeType >
double mlpack::range::RangeSearchRules< MetricType, TreeType >::Score ( TreeType &  queryNode,
TreeType &  referenceNode 
)

Get the score for recursion order.

Dual-tree scoring function.

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.

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