MLPACK  1.0.4
polynomial_kernel.hpp
Go to the documentation of this file.
00001 
00022 #ifndef __MLPACK_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
00023 #define __MLPACK_CORE_KERNELS_POLYNOMIAL_KERNEL_HPP
00024 
00025 #include <mlpack/core.hpp>
00026 
00027 namespace mlpack {
00028 namespace kernel {
00029 
00039 class PolynomialKernel
00040 {
00041  public:
00045   PolynomialKernel() :
00046     offset(0.0),
00047     degree(1.0)
00048   { }
00049 
00050   /* Construct the Polynomial Kernel with custom
00051    * offset and degree
00052    *
00053    * @param offset offset to the polynomial
00054    * @param degree degree of the polynomial
00055    */
00056   PolynomialKernel(double offset, double degree) :
00057     offset(offset),
00058     degree(degree)
00059   { }
00060 
00070   template<typename VecType>
00071   double Evaluate(const VecType& a, const VecType& b)
00072   {
00073     return pow((arma::dot(a, b) + offset), degree);
00074   }
00075 
00077   const double& Offset() const { return offset; }
00079   const double& Degree() const { return degree; }
00080 
00081  private:
00082   double offset;
00083   double degree;
00084 };
00085 
00086 }; // namespace kernel
00087 }; // namespace mlpack
00088 
00089 #endif