mlpack  2.0.1
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType > Class Template Reference

Public Types

typedef NeighborSearchTraversalInfo< TreeType > TraversalInfoType
 Convenience typedef. More...
 

Public Member Functions

 NeighborSearchRules (const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, arma::Mat< size_t > &neighbors, arma::mat &distances, MetricType &metric, const bool sameSet=false)
 
double BaseCase (const size_t queryIndex, const size_t referenceIndex)
 Get the distance from the query point to the reference point. More...
 
size_t BaseCases () const
 Get the number of base cases that have been performed. More...
 
size_t & BaseCases ()
 Modify the number of base cases that have been performed. 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 have been performed. More...
 
size_t & Scores ()
 Modify the number of scores that have been performed. More...
 
const TraversalInfoTypeTraversalInfo () const
 Get the traversal info. More...
 
TraversalInfoTypeTraversalInfo ()
 Modify the traversal info. More...
 

Protected Member Functions

double CalculateBound (TreeType &queryNode) const
 Recalculate the bound for a given query node. More...
 
void InsertNeighbor (const size_t queryIndex, const size_t pos, const size_t neighbor, const double distance)
 Insert a point into the neighbors and distances matrices; this is a helper function. More...
 

Protected Attributes

size_t baseCases
 The number of base cases that have been performed. More...
 
arma::mat & distances
 The matrix the resultant neighbor distances should be stored in. More...
 
double lastBaseCase
 The last base case result. More...
 
size_t lastQueryIndex
 The last query point BaseCase() was called with. More...
 
size_t lastReferenceIndex
 The last reference point BaseCase() was called with. More...
 
MetricType & metric
 The instantiated metric. More...
 
arma::Mat< size_t > & neighbors
 The matrix the resultant neighbor indices should be stored in. More...
 
const TreeType::Mat & querySet
 The query set. More...
 
const TreeType::Mat & referenceSet
 The reference set. More...
 
bool sameSet
 Denotes whether or not the reference and query sets are the same. More...
 
size_t scores
 The number of scores that have been performed. More...
 
TraversalInfoType traversalInfo
 Traversal info for the parent combination; this is updated by the traversal before each call to Score(). More...
 

Detailed Description

template<typename SortPolicy, typename MetricType, typename TreeType>
class mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >

Definition at line 24 of file neighbor_search_rules.hpp.

Member Typedef Documentation

◆ TraversalInfoType

template<typename SortPolicy , typename MetricType , typename TreeType >
typedef NeighborSearchTraversalInfo<TreeType> mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::TraversalInfoType

Convenience typedef.

Definition at line 104 of file neighbor_search_rules.hpp.

Constructor & Destructor Documentation

◆ NeighborSearchRules()

template<typename SortPolicy , typename MetricType , typename TreeType >
mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::NeighborSearchRules ( const typename TreeType::Mat &  referenceSet,
const typename TreeType::Mat &  querySet,
arma::Mat< size_t > &  neighbors,
arma::mat &  distances,
MetricType &  metric,
const bool  sameSet = false 
)

Member Function Documentation

◆ BaseCase()

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::BaseCase ( const size_t  queryIndex,
const size_t  referenceIndex 
)

Get the distance from the query point to the reference point.

This will update the "neighbor" matrix with the new point if appropriate and will track the number of base cases (number of points evaluated).

Parameters
queryIndexIndex of query point.
referenceIndexIndex of reference point.

◆ BaseCases() [1/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::BaseCases ( ) const
inline

Get the number of base cases that have been performed.

Definition at line 94 of file neighbor_search_rules.hpp.

References mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::baseCases.

◆ BaseCases() [2/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::BaseCases ( )
inline

Modify the number of base cases that have been performed.

Definition at line 96 of file neighbor_search_rules.hpp.

References mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::baseCases.

◆ CalculateBound()

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::CalculateBound ( TreeType &  queryNode) const
protected

Recalculate the bound for a given query node.

◆ InsertNeighbor()

template<typename SortPolicy , typename MetricType , typename TreeType >
void mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::InsertNeighbor ( const size_t  queryIndex,
const size_t  pos,
const size_t  neighbor,
const double  distance 
)
protected

Insert a point into the neighbors and distances matrices; this is a helper function.

Parameters
queryIndexIndex of point whose neighbors we are inserting into.
posPosition in list to insert into.
neighborIndex of reference point which is being inserted.
distanceDistance from query point to reference point.

◆ Rescore() [1/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, 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()).

◆ Rescore() [2/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, 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 Socre() (or Rescore()).

◆ Score() [1/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, 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.

◆ Score() [2/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::Score ( TreeType &  queryNode,
TreeType &  referenceNode 
)

Get the score for recursion order.

A low score indicates priority for recursionm 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.

◆ Scores() [1/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::Scores ( ) const
inline

Get the number of scores that have been performed.

Definition at line 99 of file neighbor_search_rules.hpp.

References mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::scores.

◆ Scores() [2/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::Scores ( )
inline

Modify the number of scores that have been performed.

Definition at line 101 of file neighbor_search_rules.hpp.

References mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::scores.

◆ TraversalInfo() [1/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
const TraversalInfoType& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::TraversalInfo ( ) const
inline

◆ TraversalInfo() [2/2]

template<typename SortPolicy , typename MetricType , typename TreeType >
TraversalInfoType& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::TraversalInfo ( )
inline

Member Data Documentation

◆ baseCases

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::baseCases
protected

The number of base cases that have been performed.

Definition at line 138 of file neighbor_search_rules.hpp.

Referenced by mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::BaseCases().

◆ distances

template<typename SortPolicy , typename MetricType , typename TreeType >
arma::mat& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::distances
protected

The matrix the resultant neighbor distances should be stored in.

Definition at line 122 of file neighbor_search_rules.hpp.

◆ lastBaseCase

template<typename SortPolicy , typename MetricType , typename TreeType >
double mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::lastBaseCase
protected

The last base case result.

Definition at line 135 of file neighbor_search_rules.hpp.

◆ lastQueryIndex

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::lastQueryIndex
protected

The last query point BaseCase() was called with.

Definition at line 131 of file neighbor_search_rules.hpp.

◆ lastReferenceIndex

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::lastReferenceIndex
protected

The last reference point BaseCase() was called with.

Definition at line 133 of file neighbor_search_rules.hpp.

◆ metric

template<typename SortPolicy , typename MetricType , typename TreeType >
MetricType& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::metric
protected

The instantiated metric.

Definition at line 125 of file neighbor_search_rules.hpp.

◆ neighbors

template<typename SortPolicy , typename MetricType , typename TreeType >
arma::Mat<size_t>& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::neighbors
protected

The matrix the resultant neighbor indices should be stored in.

Definition at line 119 of file neighbor_search_rules.hpp.

◆ querySet

template<typename SortPolicy , typename MetricType , typename TreeType >
const TreeType::Mat& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::querySet
protected

The query set.

Definition at line 116 of file neighbor_search_rules.hpp.

◆ referenceSet

template<typename SortPolicy , typename MetricType , typename TreeType >
const TreeType::Mat& mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::referenceSet
protected

The reference set.

Definition at line 113 of file neighbor_search_rules.hpp.

◆ sameSet

template<typename SortPolicy , typename MetricType , typename TreeType >
bool mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::sameSet
protected

Denotes whether or not the reference and query sets are the same.

Definition at line 128 of file neighbor_search_rules.hpp.

◆ scores

template<typename SortPolicy , typename MetricType , typename TreeType >
size_t mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::scores
protected

The number of scores that have been performed.

Definition at line 140 of file neighbor_search_rules.hpp.

Referenced by mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::Scores().

◆ traversalInfo

template<typename SortPolicy , typename MetricType , typename TreeType >
TraversalInfoType mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::traversalInfo
protected

Traversal info for the parent combination; this is updated by the traversal before each call to Score().

Definition at line 144 of file neighbor_search_rules.hpp.

Referenced by mlpack::neighbor::NeighborSearchRules< SortPolicy, MetricType, TreeType >::TraversalInfo().


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