range_search_rules.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_RULES_HPP
13 #define MLPACK_METHODS_RANGE_SEARCH_RANGE_SEARCH_RULES_HPP
14 
16 
17 namespace mlpack {
18 namespace range {
19 
27 template<typename MetricType, typename TreeType>
29 {
30  public:
44  RangeSearchRules(const arma::mat& referenceSet,
45  const arma::mat& querySet,
46  const math::Range& range,
47  std::vector<std::vector<size_t> >& neighbors,
48  std::vector<std::vector<double> >& distances,
49  MetricType& metric,
50  const bool sameSet = false);
51 
58  double BaseCase(const size_t queryIndex, const size_t referenceIndex);
59 
68  double Score(const size_t queryIndex, TreeType& referenceNode);
69 
81  double Rescore(const size_t queryIndex,
82  TreeType& referenceNode,
83  const double oldScore) const;
84 
93  double Score(TreeType& queryNode, TreeType& referenceNode);
94 
106  double Rescore(TreeType& queryNode,
107  TreeType& referenceNode,
108  const double oldScore) const;
109 
111 
112  const TraversalInfoType& TraversalInfo() const { return traversalInfo; }
113  TraversalInfoType& TraversalInfo() { return traversalInfo; }
114 
116  size_t BaseCases() const { return baseCases; }
118  size_t Scores() const { return scores; }
119 
122  size_t MinimumBaseCases() const { return 0; }
123 
124  private:
126  const arma::mat& referenceSet;
127 
129  const arma::mat& querySet;
130 
132  const math::Range& range;
133 
135  std::vector<std::vector<size_t> >& neighbors;
136 
138  std::vector<std::vector<double> >& distances;
139 
141  MetricType& metric;
142 
144  bool sameSet;
145 
147  size_t lastQueryIndex;
149  size_t lastReferenceIndex;
150 
154  void AddResult(const size_t queryIndex,
155  TreeType& referenceNode);
156 
157  TraversalInfoType traversalInfo;
158 
160  size_t baseCases;
162  size_t scores;
163 };
164 
165 } // namespace range
166 } // namespace mlpack
167 
168 // Include implementation.
169 #include "range_search_rules_impl.hpp"
170 
171 #endif
The TraversalInfo class holds traversal information which is used in dual-tree (and single-tree) trav...
Linear algebra utility functions, generally performed on matrices or vectors.
double Score(const size_t queryIndex, TreeType &referenceNode)
Get the score for recursion order.
size_t Scores() const
Get the number of scores (that is, calls to RangeDistance()).
const TraversalInfoType & TraversalInfo() const
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore) const
Re-evaluate the score for recursion order.
size_t BaseCases() const
Get the number of base cases.
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
Compute the base case between the given query point and reference point.
The RangeSearchRules class is a template helper class used by RangeSearch class when performing range...
tree::TraversalInfo< TreeType > TraversalInfoType
size_t MinimumBaseCases() const
Get the minimum number of base cases we need to perform to have acceptable results.
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.