shark::GaussianKernelMatrix< T, CacheType > Class Template Reference

Efficient special case if the kernel is Gaussian and the inputs are sparse vectors. More...

#include <shark/LinAlg/GaussianKernelMatrix.h>

Public Types

typedef CacheType QpFloatType
 
typedef T InputType
 

Public Member Functions

 GaussianKernelMatrix (double gamma, 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 Data< InputType >::const_element_range::iterator PointerType
 

Protected Attributes

std::vector< PointerTypex
 Array of data pointers for kernel evaluations. More...
 
RealVector m_squaredNorms
 
double m_gamma
 
unsigned long long m_accessCounter
 counter for the kernel accesses More...
 

Detailed Description

template<class T, class CacheType>
class shark::GaussianKernelMatrix< T, CacheType >

Efficient special case if the kernel is Gaussian and the inputs are sparse vectors.

Definition at line 54 of file GaussianKernelMatrix.h.

Member Typedef Documentation

◆ InputType

template<class T, class CacheType>
typedef T shark::GaussianKernelMatrix< T, CacheType >::InputType

Definition at line 59 of file GaussianKernelMatrix.h.

◆ PointerType

template<class T, class CacheType>
typedef Data<InputType>::const_element_range::iterator shark::GaussianKernelMatrix< T, CacheType >::PointerType
protected

Definition at line 140 of file GaussianKernelMatrix.h.

◆ QpFloatType

template<class T, class CacheType>
typedef CacheType shark::GaussianKernelMatrix< T, CacheType >::QpFloatType

Definition at line 58 of file GaussianKernelMatrix.h.

Constructor & Destructor Documentation

◆ GaussianKernelMatrix()

template<class T, class CacheType>
shark::GaussianKernelMatrix< T, CacheType >::GaussianKernelMatrix ( double  gamma,
Data< InputType > const &  data 
)
inline

Constructor

Parameters
gammabandwidth parameter of Gaussian kernel
datadata evaluated by the kernel function

Definition at line 64 of file GaussianKernelMatrix.h.

References shark::Data< Type >::elements(), shark::GaussianKernelMatrix< T, CacheType >::m_squaredNorms, shark::Data< Type >::numberOfElements(), and shark::GaussianKernelMatrix< T, CacheType >::x.

Member Function Documentation

◆ entry()

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

◆ flipColumnsAndRows()

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

◆ getAccessCount()

template<class T, class CacheType>
unsigned long long shark::GaussianKernelMatrix< T, CacheType >::getAccessCount ( ) const
inline

query the kernel access counter

Definition at line 130 of file GaussianKernelMatrix.h.

References shark::GaussianKernelMatrix< T, CacheType >::m_accessCounter.

◆ matrix()

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

◆ operator()()

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

return a single matrix entry

Definition at line 82 of file GaussianKernelMatrix.h.

References shark::GaussianKernelMatrix< T, CacheType >::entry().

◆ resetAccessCount()

template<class T, class CacheType>
void shark::GaussianKernelMatrix< T, CacheType >::resetAccessCount ( )
inline

reset the kernel access counter

Definition at line 134 of file GaussianKernelMatrix.h.

References shark::GaussianKernelMatrix< T, CacheType >::m_accessCounter.

◆ row()

template<class T, class CacheType>
void shark::GaussianKernelMatrix< T, 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 97 of file GaussianKernelMatrix.h.

References shark::GaussianKernelMatrix< T, CacheType >::m_accessCounter, SHARK_PARALLEL_FOR, and shark::GaussianKernelMatrix< T, CacheType >::x.

Referenced by shark::GaussianKernelMatrix< T, CacheType >::matrix().

◆ size()

template<class T, class CacheType>
std::size_t shark::GaussianKernelMatrix< T, CacheType >::size ( ) const
inline

return the size of the quadratic matrix

Definition at line 126 of file GaussianKernelMatrix.h.

References shark::GaussianKernelMatrix< T, CacheType >::x.

Referenced by shark::GaussianKernelMatrix< T, CacheType >::matrix().

Member Data Documentation

◆ m_accessCounter

template<class T, class CacheType>
unsigned long long shark::GaussianKernelMatrix< T, CacheType >::m_accessCounter
mutableprotected

◆ m_gamma

template<class T, class CacheType>
double shark::GaussianKernelMatrix< T, CacheType >::m_gamma
protected

Definition at line 146 of file GaussianKernelMatrix.h.

◆ m_squaredNorms

template<class T, class CacheType>
RealVector shark::GaussianKernelMatrix< T, CacheType >::m_squaredNorms
protected

◆ x


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