36#ifndef STK_KERNEL_HAMMING_H
37#define STK_KERNEL_HAMMING_H
64 typedef typename Array::Type
Type;
95 template<
class Derived>
109 template<
class Derived>
111 :
Base(data),
lambda_(param.empty() ? 1. : param.front())
134 template<
class Derived>
137 lambda_ = (param.empty() ? 1. : param.front());
168 for(
int j=factors_.nbLevels().begin();
j < factors_.nbLevels().end(); ++
j)
169 { diagElt_ *= lambda_*lambda_*(factors_.nbLevels()[
j]-1) + 1;}
179 if (hasRun_)
return gram_(
i,
j);
181 RowVector
ind1(p_data_->row(
i),
true),
ind2(p_data_->row(
j),
true);
183 for(
int j=factors_.nbLevels().begin();
j < factors_.nbLevels().end(); ++
j)
185 value *= (
ind1[
j]==
ind2[
j]) ? lambda_*lambda_*(factors_.nbLevels()[
j]-1) + 1.
186 : lambda_*(lambda_*(factors_.nbLevels()[
j]-2) + 2.);
In this file we define the Interface base class for computing a Kernels.
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
In this file we define and implement the MultiFactor class.
bool hasRun_
true if run has been used, false otherwise
The Hamming Kernel is a kernel of the form.
Real diagElt_
diagonal element of the kernel
void setParam(ExprBase< Derived > const ¶m)
Set parameter using an array.
void setLambda(Real const &lambda)
set the lambda of the kernel
Hamming(Array const &data, Real const &lambda=1.)
constructor with a constant pointer on the data set
Hamming(Array const *p_data, ExprBase< Derived > const ¶m)
constructor with an array of parameter.
Hamming(Array const *p_data, Real const &lambda=1.)
constructor with a constant pointer on the data set
Real lambda_
lambda of the kernel
Stat::MultiFactor< Array > factors_
factors of the values
IKernelBase< Array > Base
void computeDiagonalElement()
Compute the diagonal element of the kernel.
virtual Real diag(int i) const
virtual method.
Hamming(Array const &data, ExprBase< Derived > const ¶m)
constructor with a constant pointer on the data set
Real const & lambda() const
virtual ~Hamming()
destructor
virtual Real comp(int i, int j) const
virtual method implementation.
Stat::MultiFactor< Array > const & factors() const
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
virtual bool run()
compute Gram matrix
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Computation of the MultiFactors of a 2D Container.
double Real
STK fundamental type of Real values.
The namespace STK is the main domain space of the Statistical ToolKit project.