shark::KernelMatrix< InputType, CacheType > Class Template Reference

Kernel Gram matrix. More...

#include <shark/LinAlg/KernelMatrix.h>

Public Types

typedef CacheType QpFloatType
 

Public Member Functions

 KernelMatrix (AbstractKernelFunction< InputType > const &kernelfunction, Data< InputType > const &data)
 
QpFloatType operator() (std::size_t i, std::size_t j) const
 return a single matrix entry More...
 
QpFloatType entry (std::size_t i, std::size_t j) const
 return a single matrix entry More...
 
void row (std::size_t i, std::size_t start, std::size_t end, QpFloatType *storage) const
 Computes the i-th row of the kernel matrix. More...
 
template<class M >
void matrix (blas::matrix_expression< M, blas::cpu_tag > &storage) const
 Computes the kernel-matrix. More...
 
void flipColumnsAndRows (std::size_t i, std::size_t j)
 swap two variables More...
 
std::size_t size () const
 return the size of the quadratic matrix More...
 
unsigned long long getAccessCount () const
 query the kernel access counter More...
 
void resetAccessCount ()
 reset the kernel access counter More...
 

Protected Types

typedef Batch< InputType >::const_iterator PointerType
 

Protected Attributes

const AbstractKernelFunction< InputType > & kernel
 Kernel function defining the kernel Gram matrix. More...
 
Data< InputTypem_data
 
std::vector< PointerTypex
 Array of data pointers for kernel evaluations. More...
 
unsigned long long m_accessCounter
 counter for the kernel accesses More...
 

Detailed Description

template<class InputType, class CacheType>
class shark::KernelMatrix< InputType, CacheType >

Kernel Gram matrix.

The KernelMatrix is the most prominent type of matrix for quadratic programming. It provides the Gram matrix of a fixed data set with respect to an inner product implicitly defined by a kernel function.
NOTE: The KernelMatrix class stores pointers to the data, instead of maintaining a copy of the data. Thus, it implicitly assumes that the dataset is not altered during the lifetime of the KernelMatrix object. This condition is ensured as long as the class is used via the various SVM-trainers.

Definition at line 71 of file KernelMatrix.h.

Member Typedef Documentation

◆ PointerType

template<class InputType, class CacheType>
typedef Batch<InputType>::const_iterator shark::KernelMatrix< InputType, CacheType >::PointerType
protected

Definition at line 150 of file KernelMatrix.h.

◆ QpFloatType

template<class InputType, class CacheType>
typedef CacheType shark::KernelMatrix< InputType, CacheType >::QpFloatType

Definition at line 74 of file KernelMatrix.h.

Constructor & Destructor Documentation

◆ KernelMatrix()

template<class InputType, class CacheType>
shark::KernelMatrix< InputType, CacheType >::KernelMatrix ( AbstractKernelFunction< InputType > const &  kernelfunction,
Data< InputType > const &  data 
)
inline

Constructor

Parameters
kernelfunctionkernel function defining the Gram matrix
datadata to evaluate the kernel function

Definition at line 79 of file KernelMatrix.h.

References shark::Data< Type >::elements(), shark::KernelMatrix< InputType, CacheType >::m_data, shark::Data< Type >::numberOfElements(), and shark::KernelMatrix< InputType, CacheType >::x.

Member Function Documentation

◆ entry()

template<class InputType, class CacheType>
QpFloatType shark::KernelMatrix< InputType, CacheType >::entry ( std::size_t  i,
std::size_t  j 
) const
inline

◆ flipColumnsAndRows()

template<class InputType, class CacheType>
void shark::KernelMatrix< InputType, CacheType >::flipColumnsAndRows ( std::size_t  i,
std::size_t  j 
)
inline

◆ getAccessCount()

template<class InputType, class CacheType>
unsigned long long shark::KernelMatrix< InputType, CacheType >::getAccessCount ( ) const
inline

◆ matrix()

template<class InputType, class CacheType>
template<class M >
void shark::KernelMatrix< InputType, CacheType >::matrix ( blas::matrix_expression< M, blas::cpu_tag > &  storage) const
inline

◆ operator()()

template<class InputType, class CacheType>
QpFloatType shark::KernelMatrix< InputType, CacheType >::operator() ( std::size_t  i,
std::size_t  j 
) const
inline

return a single matrix entry

Definition at line 94 of file KernelMatrix.h.

References shark::KernelMatrix< InputType, CacheType >::entry().

◆ resetAccessCount()

template<class InputType, class CacheType>
void shark::KernelMatrix< InputType, CacheType >::resetAccessCount ( )
inline

◆ row()

template<class InputType, class CacheType>
void shark::KernelMatrix< InputType, CacheType >::row ( std::size_t  i,
std::size_t  start,
std::size_t  end,
QpFloatType storage 
) const
inline

Computes the i-th row of the kernel matrix.

The entries start,...,end of the i-th row are computed and stored in storage. There must be enough room for this operation preallocated.

Definition at line 108 of file KernelMatrix.h.

References shark::AbstractKernelFunction< InputTypeT >::eval(), shark::KernelMatrix< InputType, CacheType >::kernel, shark::KernelMatrix< InputType, CacheType >::m_accessCounter, SHARK_PARALLEL_FOR, and shark::KernelMatrix< InputType, CacheType >::x.

Referenced by shark::RegularizedKernelMatrix< InputType, CacheType >::row(), and shark::ModifiedKernelMatrix< InputType, CacheType >::row().

◆ size()

template<class InputType, class CacheType>
std::size_t shark::KernelMatrix< InputType, CacheType >::size ( ) const
inline

Member Data Documentation

◆ kernel

template<class InputType, class CacheType>
const AbstractKernelFunction<InputType>& shark::KernelMatrix< InputType, CacheType >::kernel
protected

◆ m_accessCounter

template<class InputType, class CacheType>
unsigned long long shark::KernelMatrix< InputType, CacheType >::m_accessCounter
mutableprotected

◆ m_data

template<class InputType, class CacheType>
Data<InputType> shark::KernelMatrix< InputType, CacheType >::m_data
protected

◆ x


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