MLPACK  1.0.8
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 
78  private:
80  double degree;
82  double offset;
83 };
84 
85 }; // namespace kernel
86 }; // namespace mlpack
87 
88 #endif
double degree
The degree of the polynomial.
PolynomialKernel(const double degree=2.0, const double offset=0.0)
Construct the Polynomial Kernel with the given offset and degree.
double & Offset()
Modify the offset of the dot product of the arguments.
double Evaluate(const VecType &a, const VecType &b) const
Simple evaluation of the dot product.
const double & Offset() const
Get the offset of the dot product of the arguments.
const double & Degree() const
Get the degree of the polynomial.
double offset
The offset of the dot product of the arguments.
The simple polynomial kernel.
double & Degree()
Modify the degree of the polynomial.