fastmks.hpp

Go to the documentation of this file.
00001 
00023 #ifndef __MLPACK_METHODS_FASTMKS_FASTMKS_HPP
00024 #define __MLPACK_METHODS_FASTMKS_FASTMKS_HPP
00025 
00026 #include <mlpack/core.hpp>
00027 #include <mlpack/core/metrics/ip_metric.hpp>
00028 #include "fastmks_stat.hpp"
00029 #include <mlpack/core/tree/cover_tree.hpp>
00030 
00031 namespace mlpack {
00032 namespace fastmks  {
00033 
00064 template<
00065     typename KernelType,
00066     typename TreeType = tree::CoverTree<metric::IPMetric<KernelType>,
00067         tree::FirstPointIsRoot, FastMKSStat>
00068 >
00069 class FastMKS
00070 {
00071  public:
00081   FastMKS(const arma::mat& referenceSet,
00082           const bool single = false,
00083           const bool naive = false);
00084 
00095   FastMKS(const arma::mat& referenceSet,
00096           const arma::mat& querySet,
00097           const bool single = false,
00098           const bool naive = false);
00099 
00111   FastMKS(const arma::mat& referenceSet,
00112           KernelType& kernel,
00113           const bool single = false,
00114           const bool naive = false);
00115 
00128   FastMKS(const arma::mat& referenceSet,
00129           const arma::mat& querySet,
00130           KernelType& kernel,
00131           const bool single = false,
00132           const bool naive = false);
00133 
00146   FastMKS(const arma::mat& referenceSet,
00147           TreeType* referenceTree,
00148           const bool single = false,
00149           const bool naive = false);
00150 
00164   FastMKS(const arma::mat& referenceSet,
00165           TreeType* referenceTree,
00166           const arma::mat& querySet,
00167           TreeType* queryTree,
00168           const bool single = false,
00169           const bool naive = false);
00170 
00172   ~FastMKS();
00173 
00188   void Search(const size_t k,
00189               arma::Mat<size_t>& indices,
00190               arma::mat& products);
00191 
00193   const metric::IPMetric<KernelType>& Metric() const { return metric; }
00195   metric::IPMetric<KernelType>& Metric() { return metric; }
00196 
00197  private:
00199   const arma::mat& referenceSet;
00201   const arma::mat& querySet;
00202 
00204   TreeType* referenceTree;
00207   TreeType* queryTree;
00208 
00210   bool treeOwner;
00211 
00213   bool single;
00215   bool naive;
00216 
00218   metric::IPMetric<KernelType> metric;
00219 
00221   void InsertNeighbor(arma::Mat<size_t>& indices,
00222                       arma::mat& products,
00223                       const size_t queryIndex,
00224                       const size_t pos,
00225                       const size_t neighbor,
00226                       const double distance);
00227 };
00228 
00229 }; // namespace fastmks
00230 }; // namespace mlpack
00231 
00232 // Include implementation.
00233 #include "fastmks_impl.hpp"
00234 
00235 #endif

Generated on 29 Sep 2016 for MLPACK by  doxygen 1.6.1