36#ifndef STK_KERNEL_POLYNOMIAL_H
37#define STK_KERNEL_POLYNOMIAL_H
59 typedef typename Array::Type
Type;
95 template<
class Derived>
98 ,
d_(param.empty() ? 2. : param.front())
99 ,
shift_(param.empty() ? 2. : param.elt(param.begin()+1))
105 template<
class Derived>
108 ,
d_(param.empty() ? 2. : param.front())
109 ,
shift_(param.empty() ? 2. : param.elt(param.begin()+1))
125 template<
class Derived>
127 {
d_ = (param.empty() ? 2. : param.front());
128 shift_ = (param.empty() ? 0. : param.elt(param.begin()+1));
155{
return hasRun_ ? gram_(
i,
i)
156 : std::pow(p_data_->row(
i).norm2() + shift_, d_);
161{
return hasRun_ ? gram_(
i,
j)
162 : std::pow(p_data_->row(
i).dot(p_data_->row(
j)) + shift_, d_);}
In this file we define the Interface base class for computing a Kernels.
#define STKDOMAIN_ERROR_2ARG(Where, Arg1, Arg2, Error)
bool hasRun_
true if run has been used, false otherwise
Interface Base class for the kernels classes.
Array const * p_data_
pointer on the data set
CSquareX gram_
the resulting gram_ matrix
Array const * p_data() const
The Polynomial Kernel is a kernel of the form.
Polynomial(Array const &data, ExprBase< Derived > const ¶m)
constructor with a constant pointer on the data set
virtual Real diag(int i) const
virtual method.
Real const & degree() const
Polynomial(Real const &d=2., Real const &shift=0)
Default constructor with the degree and the shift.
void setParam(ExprBase< Derived > const ¶m)
Set parameter using an array.
Real d_
degree of the kernel
Polynomial(Array const *p_data, ExprBase< Derived > const ¶m)
constructor with an array of parameter.
virtual ~Polynomial()
destructor
void setDegree(Real const &d)
set the degree of the kernel
IKernelBase< Array > Base
virtual Real comp(int i, int j) const
virtual method implementation.
Real const & shift() const
Polynomial(Array const &data, Real const &d=2., Real const &shift=0.)
constructor with a constant reference on the data set
Real shift_
shift of the kernel
Polynomial(Array const *p_data, Real const &d=2., Real const &shift=0)
constructor with a constant pointer on the data set
void setShift(Real const &shift)
set the shift of the kernel
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.