mlpack: src/mlpack/core/kernels/polynomial_kernel.hpp Source File
 mlpack  2.0.2
polynomial_kernel.hpp
Go to the documentation of this file.
1
14 #ifndef mlpack_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
15 #define mlpack_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
16
17 #include <mlpack/core.hpp>
18
19 namespace mlpack {
20 namespace kernel {
21
31 {
32  public:
40  PolynomialKernel(const double degree = 2.0, const double offset = 0.0) :
41  degree(degree),
42  offset(offset)
43  { }
44
56  template<typename VecTypeA, typename VecTypeB>
57  double Evaluate(const VecTypeA& a, const VecTypeB& b) const
58  {
59  return pow((arma::dot(a, b) + offset), degree);
60  }
61
63  const double& Degree() const { return degree; }
65  double& Degree() { return degree; }
66
68  const double& Offset() const { return offset; }
70  double& Offset() { return offset; }
71
73  template<typename Archive>
74  void Serialize(Archive& ar, const unsigned int /* version */)
75  {
76  ar & data::CreateNVP(degree, "degree");
77  ar & data::CreateNVP(offset, "offset");
78  }
79
80  private:
82  double degree;
84  double offset;
85 };
86
87 } // namespace kernel
88 } // namespace mlpack
89
90 #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.
Linear algebra utility functions, generally performed on matrices or vectors.
FirstShim< T > CreateNVP(T &t, const std::string &name, typename boost::enable_if< HasSerialize< T >>::type *=0)
Call this function to produce a name-value pair; this is similar to BOOST_SERIALIZATION_NVP(), but should be used for types that have a Serialize() function (or contain a type that has a Serialize() function) instead of a serialize() function.
double & Offset()
Modify the offset of the dot product of the arguments.
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.
void Serialize(Archive &ar, const unsigned int)
Serialize the kernel.
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
The simple polynomial kernel.
double & Degree()
Modify the degree of the polynomial.
double Evaluate(const VecTypeA &a, const VecTypeB &b) const
Simple evaluation of the dot product.