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

SVM ranking matrix. More...

#include <shark/LinAlg/DifferenceKernelMatrix.h>

Public Types

typedef CacheType QpFloatType
 

Public Member Functions

 DifferenceKernelMatrix (AbstractKernelFunction< InputType > const &kernel, Data< InputType > const &dataset, std::vector< std::pair< std::size_t, std::size_t >> const &pairs)
 Constructor. More...
 
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...
 

Protected Attributes

AbstractKernelFunction< InputType > const & m_kernel
 underlying kernel function More...
 
Data< InputType > const & m_dataset
 underlying set of points More...
 
std::vector< std::tuple< std::size_t, std::size_t, std::size_t, std::size_t > > m_indices
 pairs of points defining the matrix components More...
 

Detailed Description

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

SVM ranking matrix.

The DifferenceKernelMatrix class is kernel matrix with entries of the form \( K_{i,j} = k(g_i, g_j) - k(g_i, s_j) - k(s_i, g_j) + k(s_i, s_j) \) where for data consisting of pairs of point \( (g_i, s_i) \). This matrix form is needed in SVM ranking problems.

Definition at line 64 of file DifferenceKernelMatrix.h.

Member Typedef Documentation

◆ QpFloatType

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

Definition at line 67 of file DifferenceKernelMatrix.h.

Constructor & Destructor Documentation

◆ DifferenceKernelMatrix()

template<class InputType, class CacheType>
shark::DifferenceKernelMatrix< InputType, CacheType >::DifferenceKernelMatrix ( AbstractKernelFunction< InputType > const &  kernel,
Data< InputType > const &  dataset,
std::vector< std::pair< std::size_t, std::size_t >> const &  pairs 
)
inline

Member Function Documentation

◆ entry()

◆ flipColumnsAndRows()

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

◆ matrix()

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

◆ operator()()

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

return a single matrix entry

Definition at line 90 of file DifferenceKernelMatrix.h.

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

◆ row()

template<class InputType, class CacheType>
void shark::DifferenceKernelMatrix< 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 122 of file DifferenceKernelMatrix.h.

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

◆ size()

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

Member Data Documentation

◆ m_dataset

template<class InputType, class CacheType>
Data<InputType> const& shark::DifferenceKernelMatrix< InputType, CacheType >::m_dataset
protected

underlying set of points

Definition at line 152 of file DifferenceKernelMatrix.h.

Referenced by shark::DifferenceKernelMatrix< InputType, CacheType >::entry().

◆ m_indices

template<class InputType, class CacheType>
std::vector<std::tuple<std::size_t, std::size_t, std::size_t, std::size_t> > shark::DifferenceKernelMatrix< InputType, CacheType >::m_indices
protected

◆ m_kernel

template<class InputType, class CacheType>
AbstractKernelFunction<InputType> const& shark::DifferenceKernelMatrix< InputType, CacheType >::m_kernel
protected

underlying kernel function

Definition at line 149 of file DifferenceKernelMatrix.h.

Referenced by shark::DifferenceKernelMatrix< InputType, CacheType >::entry().


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