MLPACK  1.0.10
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 
200  std::string ToString() const;
201 
202  private:
204  const arma::mat& referenceSet;
206  const arma::mat& querySet;
207 
209  TreeType* referenceTree;
212  TreeType* queryTree;
213 
215  bool treeOwner;
216 
218  bool single;
220  bool naive;
221 
224 
226  void InsertNeighbor(arma::Mat<size_t>& indices,
227  arma::mat& products,
228  const size_t queryIndex,
229  const size_t pos,
230  const size_t neighbor,
231  const double distance);
232 };
233 
234 }; // namespace fastmks
235 }; // namespace mlpack
236 
237 // Include implementation.
238 #include "fastmks_impl.hpp"
239 
240 #endif