mlpack
fastmks_model.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_HPP
13 #define MLPACK_METHODS_FASTMKS_FASTMKS_MODEL_HPP
14 
15 #include <mlpack/prereqs.hpp>
16 #include "fastmks.hpp"
28 
29 namespace mlpack {
30 namespace fastmks {
31 
35 {
36  public:
39  {
40  LINEAR_KERNEL,
41  POLYNOMIAL_KERNEL,
42  COSINE_DISTANCE,
43  GAUSSIAN_KERNEL,
44  EPANECHNIKOV_KERNEL,
45  TRIANGULAR_KERNEL,
46  HYPTAN_KERNEL
47  };
48 
52  FastMKSModel(const int kernelType = LINEAR_KERNEL);
53 
55  FastMKSModel(const FastMKSModel& other);
56 
58  FastMKSModel(FastMKSModel&& other);
59 
61  FastMKSModel& operator=(const FastMKSModel& other);
62 
65 
69  ~FastMKSModel();
70 
75  template<typename TKernelType>
76  void BuildModel(arma::mat&& referenceData,
77  TKernelType& kernel,
78  const bool singleMode,
79  const bool naive,
80  const double base);
81 
83  bool Naive() const;
85  bool& Naive();
86 
88  bool SingleMode() const;
90  bool& SingleMode();
91 
93  int KernelType() const { return kernelType; }
95  int& KernelType() { return kernelType; }
96 
109  void Search(const arma::mat& querySet,
110  const size_t k,
111  arma::Mat<size_t>& indices,
112  arma::mat& kernels,
113  const double base);
114 
124  void Search(const size_t k,
125  arma::Mat<size_t>& indices,
126  arma::mat& kernels);
127 
131  template<typename Archive>
132  void serialize(Archive& ar, const uint32_t /* version */);
133 
134  private:
136  int kernelType;
137 
152 
154  template<typename FastMKSType>
155  void Search(FastMKSType& f,
156  const arma::mat& querySet,
157  const size_t k,
158  arma::Mat<size_t>& indices,
159  arma::mat& kernels,
160  const double base);
161 };
162 
163 } // namespace fastmks
164 } // namespace mlpack
165 
166 #include "fastmks_model_impl.hpp"
167 
168 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
void Search(const arma::mat &querySet, const size_t k, arma::Mat< size_t > &indices, arma::mat &kernels, const double base)
Search with a different query set.
Definition: fastmks_model.cpp:250
FastMKSModel(const int kernelType=LINEAR_KERNEL)
Create the FastMKSModel with the given kernel type.
Definition: fastmks_model.cpp:18
int KernelType() const
Get the kernel type.
Definition: fastmks_model.hpp:93
void BuildModel(arma::mat &&referenceData, TKernelType &kernel, const bool singleMode, const bool naive, const double base)
Build the model on the given reference set.
Definition: fastmks_model_impl.hpp:64
bool Naive() const
Get whether or not naive search is used.
Definition: fastmks_model.cpp:158
FastMKSModel & operator=(const FastMKSModel &other)
Copy assignment operator.
Definition: fastmks_model.cpp:72
bool SingleMode() const
Get whether or not single-tree search is used.
Definition: fastmks_model.cpp:204
int & KernelType()
Modify the kernel type.
Definition: fastmks_model.hpp:95
A utility struct to contain all the possible FastMKS models, for use by the mlpack_fastmks program...
Definition: fastmks_model.hpp:34
KernelTypes
A list of all the kernels we support.
Definition: fastmks_model.hpp:38
An implementation of fast exact max-kernel search.
Definition: fastmks.hpp:63
void serialize(Archive &ar, const uint32_t)
Serialize the model.
Definition: fastmks_model_impl.hpp:135
~FastMKSModel()
Clean memory.
Definition: fastmks_model.cpp:139