MLPACK  1.0.10
polynomial_kernel.hpp
Go to the documentation of this file.
1 
22 #ifndef __MLPACK_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
23 #define __MLPACK_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
24 
25 #include <mlpack/core.hpp>
26 
27 namespace mlpack {
28 namespace kernel {
29 
39 {
40  public:
48  PolynomialKernel(const double degree = 2.0, const double offset = 0.0) :
49  degree(degree),
50  offset(offset)
51  { }
52 
62  template<typename VecType>
63  double Evaluate(const VecType& a, const VecType& b) const
64  {
65  return pow((arma::dot(a, b) + offset), degree);
66  }
67 
69  const double& Degree() const { return degree; }
71  double& Degree() { return degree; }
72 
74  const double& Offset() const { return offset; }
76  double& Offset() { return offset; }
77 
79  std::string ToString() const
80  {
81  std::ostringstream convert;
82  convert << "PolynomialKernel [" << this << "]" << std::endl;
83  convert << " Degree: " << degree << std::endl;
84  convert << " Offset: " << offset << std::endl;
85  return convert.str();
86  }
87 
88  private:
90  double degree;
92  double offset;
93 };
94 
95 }; // namespace kernel
96 }; // namespace mlpack
97 
98 #endif