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

Interface Base class for the kernels classes. More...

#include <STK_Kernel_IKernelBase.h>

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

Public Types

typedef Array::Type Type
 

Public Member Functions

 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
 
virtual Real value (Type const &v) const
 compute the value of the kernel for the given value
 
- 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
 
virtual Real comp (int i, int j) const =0
 pure virtual method.
 
Real dist (int i, int j) const
 
virtual Real diag (int i) const
 virtual method.
 
- Public Member Functions inherited from STK::IRunnerBase
String const & error () const
 get the last error message.
 

Public Attributes

CSquareX gram_
 the resulting gram_ matrix
 

Protected Attributes

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
 

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.
 

Detailed Description

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

Interface Base class for the kernels classes.

Definition at line 49 of file STK_Kernel_IKernelBase.h.

Member Typedef Documentation

◆ Type

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

Definition at line 52 of file STK_Kernel_IKernelBase.h.

Constructor & Destructor Documentation

◆ IKernelBase() [1/3]

template<class Array >
STK::Kernel::IKernelBase< Array >::IKernelBase ( Array const *  p_data)
inline

constructor with a constant pointer on the data set

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

Definition at line 58 of file STK_Kernel_IKernelBase.h.

58: IKernel(), p_data_(p_data) {}
Array const * p_data_
pointer on the data set
IKernel()
default constructor

◆ IKernelBase() [2/3]

template<class Array >
STK::Kernel::IKernelBase< Array >::IKernelBase ( Array const &  data)
inline

constructor with a constant reference on the data set

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

Definition at line 62 of file STK_Kernel_IKernelBase.h.

62: IKernel(), p_data_(&data) {}

◆ IKernelBase() [3/3]

template<class Array >
STK::Kernel::IKernelBase< Array >::IKernelBase ( IKernelBase< Array > const &  kernel)
inline

copy constructor

Parameters
kernelkernel to copy

Definition at line 66 of file STK_Kernel_IKernelBase.h.

66: IKernel(kernel), p_data_(kernel.p_data_) {}

◆ ~IKernelBase()

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

destructor

Definition at line 68 of file STK_Kernel_IKernelBase.h.

68{}

Member Function Documentation

◆ nbSample()

template<class Array >
virtual int STK::Kernel::IKernelBase< Array >::nbSample ( ) const
inlinevirtual
Returns
the number of samples (the number of rows in the data set)

Implements STK::Kernel::IKernel.

Definition at line 77 of file STK_Kernel_IKernelBase.h.

77{ return (p_data_) ? p_data_->sizeRows() : 0;}

References STK::Kernel::IKernelBase< Array >::p_data_.

◆ nbVariable()

template<class Array >
virtual int STK::Kernel::IKernelBase< Array >::nbVariable ( ) const
inlinevirtual
Returns
the number of variables (the number of columns in the data set)

Implements STK::Kernel::IKernel.

Definition at line 79 of file STK_Kernel_IKernelBase.h.

79{ return (p_data_) ? p_data_->sizeCols() : 0;}

References STK::Kernel::IKernelBase< Array >::p_data_.

◆ p_data()

template<class Array >
Array const * STK::Kernel::IKernelBase< Array >::p_data ( ) const
inline
Returns
the pointer on the data set

Definition at line 71 of file STK_Kernel_IKernelBase.h.

71{ return p_data_;}

References STK::Kernel::IKernelBase< Array >::p_data_.

Referenced by STK::Kernel::Hamming< Array >::Hamming(), and STK::Kernel::Hamming< Array >::Hamming().

◆ run()

template<class Array >
bool STK::Kernel::IKernelBase< Array >::run ( )
virtual

compute Gram matrix

Returns
true if the computation is successful, false otherwise

Implements STK::IRunnerBase.

Definition at line 94 of file STK_Kernel_IKernelBase.h.

95{
96 if(!p_data_) return false;
97 gram_.resize(p_data_->rows());
98 // upper part
99 for (int j= gram_.begin(); j < gram_.end(); ++j)
100 {
101 { gram_(j,j) = this->diag(j);}
102 for (int i= j+1; i < gram_.end(); ++i)
103 { gram_(i,j) = this->comp(i,j);}
104 }
105 // lower part
106 for (int j= gram_.begin(); j < gram_.end(); ++j)
107 {
108 for (int i= j+1; i < gram_.end(); ++i)
109 { gram_(j,i) = gram_(i,j);}
110 }
111 this->hasRun_ = true;
112 return true;
113}
Derived & resize(Range const &I, Range const &J)
resize the Array.
bool hasRun_
true if run has been used, false otherwise
Definition STK_IRunner.h:98
CSquareX gram_
the resulting gram_ matrix
virtual Real diag(int i) const
virtual method.
virtual Real comp(int i, int j) const =0
pure virtual method.

Referenced by STK::Kernel::Hamming< Array >::Hamming(), and STK::Kernel::Hamming< Array >::Hamming().

◆ value()

template<class Array >
virtual Real STK::Kernel::IKernelBase< 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 in STK::Kernel::Gaussian< Array >, STK::Kernel::Laplace< Array >, STK::Kernel::Exponential< Array >, and STK::Kernel::RationalQuadratic< Array >.

Definition at line 85 of file STK_Kernel_IKernelBase.h.

86 { return 0;}

Member Data Documentation

◆ gram_

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

the resulting gram_ matrix

Definition at line 123 of file STK_Kernel_IKernel.h.

◆ p_data_

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

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