STK++ 0.9.13
STK::Kernel::Exponential< Array > Class Template Reference

[Deprecated] The Exponential Kernel is a kernel of the form More...

#include <STK_Kernel_Laplace.h>

Inheritance diagram for STK::Kernel::Exponential< Array >:
Inheritance graph

Public Types

typedef IKernelBase< Array > Base
 
typedef Array::Type Type
 
- Public Types inherited from STK::Kernel::IKernelBase< Array >
typedef Array::Type Type
 

Public Member Functions

 Exponential (Real const &width=1.)
 Default constructor with the width.
 
 Exponential (Array const *p_data, Real const &width=1.)
 constructor with a constant pointer on the data set
 
 Exponential (Array const &data, Real const &width=1.)
 constructor with a constant pointer on the data set
 
template<class Derived >
 Exponential (Array const *p_data, ExprBase< Derived > const &param)
 constructor with an array of parameter.
 
template<class Derived >
 Exponential (Array const &data, ExprBase< Derived > const &param)
 constructor with a constant pointer on the data set
 
virtual ~Exponential ()
 destructor
 
Real const & width () const
 
void setWidth (Real const &width)
 set the bandwidth of the kernel
 
template<class Derived >
void setParam (ExprBase< Derived > const &param)
 Set parameter using an array.
 
virtual Real diag (int i) const
 virtual method.
 
virtual Real comp (int i, int j) const
 virtual method implementation.
 
virtual Real value (Type const &v) const
 compute the value of the kernel for the given value
 
- Public Member Functions inherited from STK::Kernel::IKernelBase< Array >
 IKernelBase (Array const *p_data)
 constructor with a constant pointer on the data set
 
 IKernelBase (Array const &data)
 constructor with a constant reference on the data set
 
 IKernelBase (IKernelBase const &kernel)
 copy constructor
 
virtual ~IKernelBase ()
 destructor
 
Array const * p_data () const
 
virtual bool run ()
 compute Gram matrix
 
virtual int nbSample () const
 
virtual int nbVariable () const
 
- Public Member Functions inherited from STK::Kernel::IKernel
 IKernel ()
 default constructor
 
 IKernel (IKernel const &kernel)
 copy constructor
 
virtual ~IKernel ()
 destructor
 
CSquareX const & k () const
 
CSquareX const & gram () const
 
Real kcomp (int i, int j) const
 
Real kdist (int i, int j) const
 
Real kdiag (int i) const
 
Real dist (int i, int j) const
 
- Public Member Functions inherited from STK::IRunnerBase
String const & error () const
 get the last error message.
 

Public Attributes

Array const * p_data_
 pointer on the data set
 
CSquareX gram_
 the resulting gram_ matrix
 
- Public Attributes inherited from STK::Kernel::IKernelBase< Array >
CSquareX gram_
 the resulting gram_ matrix
 

Private Attributes

Real width_
 bandwidth of the kernel
 

Additional Inherited Members

- Protected Member Functions inherited from STK::IRunnerBase
 IRunnerBase ()
 default constructor
 
 IRunnerBase (IRunnerBase const &runner)
 copy constructor
 
virtual ~IRunnerBase ()
 destructor
 
virtual void update ()
 update the runner.
 
- Protected Attributes inherited from STK::Kernel::IKernelBase< Array >
Array const * p_data_
 pointer on the data set
 
- Protected Attributes inherited from STK::Kernel::IKernel
CSquareX gram_
 the resulting gram_ matrix
 
- Protected Attributes inherited from STK::IRunnerBase
String msg_error_
 String with the last error message.
 
bool hasRun_
 true if run has been used, false otherwise
 

Detailed Description

template<class Array>
class STK::Kernel::Exponential< Array >

[Deprecated] The Exponential Kernel is a kernel of the form

\[
k(x,y) = \exp\left(- \frac{\|x-y\|}{h} \right)
\]

where h represents the bandwidth of the kernel.

Definition at line 152 of file STK_Kernel_Laplace.h.

Member Typedef Documentation

◆ Base

template<class Array >
typedef IKernelBase<Array> STK::Kernel::Exponential< Array >::Base

Definition at line 155 of file STK_Kernel_Laplace.h.

◆ Type

template<class Array >
typedef Array::Type STK::Kernel::Exponential< Array >::Type

Definition at line 156 of file STK_Kernel_Laplace.h.

Constructor & Destructor Documentation

◆ Exponential() [1/5]

template<class Array >
STK::Kernel::Exponential< Array >::Exponential ( Real const &  width = 1.)
inline

Default constructor with the width.

Parameters
widththe size of the windows to use in the kernel

Definition at line 164 of file STK_Kernel_Laplace.h.

165 : Base(0), width_(width)
166 {}
Real width_
bandwidth of the kernel
Real const & width() const
IKernelBase< Array > Base

◆ Exponential() [2/5]

template<class Array >
STK::Kernel::Exponential< Array >::Exponential ( Array const *  p_data,
Real const &  width = 1. 
)
inline

constructor with a constant pointer on the data set

Parameters
p_dataa pointer on a data set that will be "kernelized"
widththe size of the windows to use in the kernel

Definition at line 171 of file STK_Kernel_Laplace.h.

172 : Base(p_data), width_(width) {}

◆ Exponential() [3/5]

template<class Array >
STK::Kernel::Exponential< Array >::Exponential ( Array const &  data,
Real const &  width = 1. 
)
inline

constructor with a constant pointer on the data set

Parameters
dataa reference on a data set that will be "kernelized"
widththe size of the windows to use in the kernel

Definition at line 177 of file STK_Kernel_Laplace.h.

178 : Base(data), width_(width) {}

◆ Exponential() [4/5]

template<class Array >
template<class Derived >
STK::Kernel::Exponential< Array >::Exponential ( Array const *  p_data,
ExprBase< Derived > const &  param 
)
inline

constructor with an array of parameter.

Parameters
p_dataa pointer on a data set that will be "kernelized"
paramarray of parameter

Definition at line 184 of file STK_Kernel_Laplace.h.

185 : Base(p_data), width_(param.empty() ? 1. : param.front())
186 {}

◆ Exponential() [5/5]

template<class Array >
template<class Derived >
STK::Kernel::Exponential< Array >::Exponential ( Array const &  data,
ExprBase< Derived > const &  param 
)
inline

constructor with a constant pointer on the data set

Parameters
dataa reference on a data set that will be "kernelized"
paramarray of parameter

Definition at line 192 of file STK_Kernel_Laplace.h.

193 : Base(data), width_(param.empty() ? 1. : param.front())
194 {}

◆ ~Exponential()

template<class Array >
virtual STK::Kernel::Exponential< Array >::~Exponential ( )
inlinevirtual

destructor

Definition at line 197 of file STK_Kernel_Laplace.h.

197{}

Member Function Documentation

◆ comp()

template<class Array >
Real STK::Kernel::Exponential< Array >::comp ( int  i,
int  j 
) const
inlinevirtual

virtual method implementation.

Returns
value of the kernel for the ith and jth individuals.
Parameters
i,jindexes of the individuals

Implements STK::Kernel::IKernel.

Definition at line 232 of file STK_Kernel_Laplace.h.

233{
234 return hasRun_ ? gram_(i,j)
235 : std::exp(-(p_data_->row(i) - p_data_->row(j)).norm()/width_);
236}
bool hasRun_
true if run has been used, false otherwise
Definition STK_IRunner.h:98
Array const * p_data_
pointer on the data set
CSquareX gram_
the resulting gram_ matrix
Real norm(Real const &x, Real const &y)
Computation of sqrt(x^2 + y^2) without underflow or overflow.
Definition STK_Misc.h:93

◆ diag()

template<class Array >
virtual Real STK::Kernel::Exponential< Array >::diag ( int  i) const
inlinevirtual

virtual method.

Returns
diagonal value of the kernel for the ith individuals.
Parameters
iindex of the individual

Reimplemented from STK::Kernel::IKernel.

Definition at line 214 of file STK_Kernel_Laplace.h.

214{return 1.;};

◆ setParam()

template<class Array >
template<class Derived >
void STK::Kernel::Exponential< Array >::setParam ( ExprBase< Derived > const &  param)
inline

Set parameter using an array.

Parameters
paramarray of parameter

Definition at line 207 of file STK_Kernel_Laplace.h.

208 { width_ = (param.empty() ? 1. : param.front());}

References STK::Kernel::Exponential< Array >::width_.

◆ setWidth()

template<class Array >
void STK::Kernel::Exponential< Array >::setWidth ( Real const &  width)
inline

set the bandwidth of the kernel

Definition at line 202 of file STK_Kernel_Laplace.h.

202{width_ = width;}

References STK::Kernel::Exponential< Array >::width(), and STK::Kernel::Exponential< Array >::width_.

◆ value()

template<class Array >
Real STK::Kernel::Exponential< Array >::value ( Type const &  v) const
inlinevirtual

compute the value of the kernel for the given value

Parameters
vvalue
Returns
the value of the kernel at v

Reimplemented from STK::Kernel::IKernelBase< Array >.

Definition at line 239 of file STK_Kernel_Laplace.h.

240{ return std::exp(-std::abs(v)/width_);}

◆ width()

template<class Array >
Real const & STK::Kernel::Exponential< Array >::width ( ) const
inline
Returns
the bandwidth of the kernel

Definition at line 200 of file STK_Kernel_Laplace.h.

200{return width_;}

References STK::Kernel::Exponential< Array >::width_.

Referenced by STK::Kernel::Exponential< Array >::setWidth().

Member Data Documentation

◆ gram_

template<class Array >
CSquareX STK::Kernel::IKernel::gram_

the resulting gram_ matrix

Definition at line 53 of file STK_Kernel_IKernel.h.

◆ p_data_

template<class Array >
Array const* STK::Kernel::IKernelBase< Array >::p_data_

pointer on the data set

Definition at line 90 of file STK_Kernel_IKernelBase.h.

◆ width_


The documentation for this class was generated from the following file: