12 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_RULES_HPP 13 #define MLPACK_METHODS_FASTMKS_FASTMKS_RULES_HPP 19 #include <boost/heap/priority_queue.hpp> 33 template<
typename KernelType,
typename TreeType>
47 const typename TreeType::Mat& querySet,
57 void GetResults(arma::Mat<size_t>& indices, arma::mat& products);
60 double BaseCase(
const size_t queryIndex,
const size_t referenceIndex);
70 double Score(
const size_t queryIndex, TreeType& referenceNode);
80 double Score(TreeType& queryNode, TreeType& referenceNode);
93 double Rescore(
const size_t queryIndex,
94 TreeType& referenceNode,
95 const double oldScore)
const;
108 double Rescore(TreeType& queryNode,
109 TreeType& referenceNode,
110 const double oldScore)
const;
133 const typename TreeType::Mat& referenceSet;
135 const typename TreeType::Mat& querySet;
138 typedef std::pair<double, size_t> Candidate;
141 struct CandidateCmp {
142 bool operator()(
const Candidate& c1,
const Candidate& c2)
const 144 return c1.first > c2.first;
152 typedef boost::heap::priority_queue<Candidate,
153 boost::heap::compare<CandidateCmp>> CandidateList;
156 std::vector<CandidateList> candidates;
162 arma::vec queryKernels;
164 arma::vec referenceKernels;
170 size_t lastQueryIndex;
172 size_t lastReferenceIndex;
177 double CalculateBound(TreeType& queryNode)
const;
186 void InsertNeighbor(
const size_t queryIndex,
188 const double product);
195 TraversalInfoType traversalInfo;
202 #include "fastmks_rules_impl.hpp" TraversalInfoType & TraversalInfo()
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.
FastMKSRules(const typename TreeType::Mat &referenceSet, const typename TreeType::Mat &querySet, const size_t k, KernelType &kernel)
Construct the FastMKSRules object.
The core includes that mlpack expects; standard C++ includes and Armadillo.
size_t Scores() const
Get the number of times Score() was called.
const TraversalInfoType & TraversalInfo() const
size_t & BaseCases()
Modify the number of times BaseCase() was called.
double Score(const size_t queryIndex, TreeType &referenceNode)
Get the score for recursion order.
size_t BaseCases() const
Get the number of times BaseCase() was called.
double Rescore(const size_t queryIndex, TreeType &referenceNode, const double oldScore) const
Re-evaluate the score for recursion order.
double BaseCase(const size_t queryIndex, const size_t referenceIndex)
Compute the base case (kernel value) between two points.
size_t & Scores()
Modify the number of times Score() was called.
The FastMKSRules class is a template helper class used by FastMKS class when performing exact max-ker...
tree::TraversalInfo< TreeType > TraversalInfoType
size_t MinimumBaseCases() const
Get the minimum number of base cases we need to perform to have acceptable results.
void GetResults(arma::Mat< size_t > &indices, arma::mat &products)
Store the list of candidates for each query point in the given matrices.