MLPACK  1.0.8
fastmks.hpp
Go to the documentation of this file.
1 
23 #ifndef __MLPACK_METHODS_FASTMKS_FASTMKS_HPP
24 #define __MLPACK_METHODS_FASTMKS_FASTMKS_HPP
25 
26 #include <mlpack/core.hpp>
28 #include "fastmks_stat.hpp"
30 
31 namespace mlpack {
32 namespace fastmks {
33 
64 template<
65  typename KernelType,
68 >
69 class FastMKS
70 {
71  public:
81  FastMKS(const arma::mat& referenceSet,
82  const bool single = false,
83  const bool naive = false);
84 
95  FastMKS(const arma::mat& referenceSet,
96  const arma::mat& querySet,
97  const bool single = false,
98  const bool naive = false);
99 
111  FastMKS(const arma::mat& referenceSet,
112  KernelType& kernel,
113  const bool single = false,
114  const bool naive = false);
115 
128  FastMKS(const arma::mat& referenceSet,
129  const arma::mat& querySet,
130  KernelType& kernel,
131  const bool single = false,
132  const bool naive = false);
133 
146  FastMKS(const arma::mat& referenceSet,
147  TreeType* referenceTree,
148  const bool single = false,
149  const bool naive = false);
150 
164  FastMKS(const arma::mat& referenceSet,
165  TreeType* referenceTree,
166  const arma::mat& querySet,
167  TreeType* queryTree,
168  const bool single = false,
169  const bool naive = false);
170 
172  ~FastMKS();
173 
188  void Search(const size_t k,
189  arma::Mat<size_t>& indices,
190  arma::mat& products);
191 
193  const metric::IPMetric<KernelType>& Metric() const { return metric; }
196 
197  private:
199  const arma::mat& referenceSet;
201  const arma::mat& querySet;
202 
204  TreeType* referenceTree;
207  TreeType* queryTree;
208 
210  bool treeOwner;
211 
213  bool single;
215  bool naive;
216 
219 
221  void InsertNeighbor(arma::Mat<size_t>& indices,
222  arma::mat& products,
223  const size_t queryIndex,
224  const size_t pos,
225  const size_t neighbor,
226  const double distance);
227 };
228 
229 }; // namespace fastmks
230 }; // namespace mlpack
231 
232 // Include implementation.
233 #include "fastmks_impl.hpp"
234 
235 #endif
FastMKS(const arma::mat &referenceSet, const bool single=false, const bool naive=false)
Create the FastMKS object using the reference set as the query set.
void InsertNeighbor(arma::Mat< size_t > &indices, arma::mat &products, const size_t queryIndex, const size_t pos, const size_t neighbor, const double distance)
Utility function. Copied too many times from too many places.
const arma::mat & referenceSet
The reference dataset.
Definition: fastmks.hpp:199
const metric::IPMetric< KernelType > & Metric() const
Get the inner-product metric induced by the given kernel.
Definition: fastmks.hpp:193
bool treeOwner
If true, this object created the trees and is responsible for them.
Definition: fastmks.hpp:210
TreeType * queryTree
The tree built on the query dataset.
Definition: fastmks.hpp:207
TreeType * referenceTree
The tree built on the reference dataset.
Definition: fastmks.hpp:204
const arma::mat & querySet
The query dataset.
Definition: fastmks.hpp:201
metric::IPMetric< KernelType > & Metric()
Modify the inner-product metric induced by the given kernel.
Definition: fastmks.hpp:195
bool single
If true, single-tree search is used.
Definition: fastmks.hpp:213
void Search(const size_t k, arma::Mat< size_t > &indices, arma::mat &products)
Search for the maximum inner products of the query set (or if no query set was passed, the reference set is used).
bool naive
If true, naive (brute-force) search is used.
Definition: fastmks.hpp:215
The statistic used in trees with FastMKS.
~FastMKS()
Destructor for the FastMKS object.
This class is meant to be used as a choice for the policy class RootPointPolicy of the CoverTree clas...
An implementation of fast exact max-kernel search.
Definition: fastmks.hpp:69
A cover tree is a tree specifically designed to speed up nearest-neighbor computation in high-dimensi...
Definition: cover_tree.hpp:103
metric::IPMetric< KernelType > metric
The instantiated inner-product metric induced by the given kernel.
Definition: fastmks.hpp:218