shark::QpSparseArray< QpFloatType > Class Template Reference

specialized container class for multi-class SVM problems More...

#include <shark/Algorithms/QP/QpSparseArray.h>

Classes

struct  Entry
 Non-default (non-zero) array entry. More...
 
struct  Row
 Data structure describing a row of the sparse array. More...
 

Public Member Functions

 QpSparseArray (std::size_t height, std::size_t width, std::size_t space)
 
 QpSparseArray ()
 
std::size_t width () const
 number of columns More...
 
std::size_t height () const
 number of rows More...
 
QpFloatType operator() (std::size_t row, std::size_t col) const
 obtain an element of the matrix More...
 
Row const & row (std::size_t row) const
 obtain a row of the matrix More...
 
void setDefaultValue (std::size_t row, QpFloatType defaultvalue)
 
void add (std::size_t row, std::size_t col, QpFloatType value)
 
void resize (std::size_t height, std::size_t width, std::size_t space)
 

Protected Attributes

std::size_t m_width
 number of columns More...
 
std::size_t m_height
 number of rows More...
 
std::size_t m_used
 current total number of non-default components More...
 
std::vector< Entrym_data
 storage for Entry structures More...
 
std::vector< Rowm_row
 storage for Row structures More...
 

Detailed Description

template<class QpFloatType>
class shark::QpSparseArray< QpFloatType >

specialized container class for multi-class SVM problems

This sparse matrix container allows to explicitly store only those entries of a matrix row that deviate from a row wise default value. This allows for efficient storage of the "kernel modifiers" used to encode dual multi-class support vector machine problems.

Definition at line 56 of file QpSparseArray.h.

Constructor & Destructor Documentation

◆ QpSparseArray() [1/2]

template<class QpFloatType>
shark::QpSparseArray< QpFloatType >::QpSparseArray ( std::size_t  height,
std::size_t  width,
std::size_t  space 
)
inline

Constructor. The space parameter is an upper limit on the number of non-default (aka non-zero) entries of the array.

Definition at line 81 of file QpSparseArray.h.

References shark::QpSparseArray< QpFloatType >::m_row.

◆ QpSparseArray() [2/2]

template<class QpFloatType>
shark::QpSparseArray< QpFloatType >::QpSparseArray ( )
inline

Definition at line 94 of file QpSparseArray.h.

Member Function Documentation

◆ add()

template<class QpFloatType>
void shark::QpSparseArray< QpFloatType >::add ( std::size_t  row,
std::size_t  col,
QpFloatType  value 
)
inline

Set a specific value. Note that entries can not be changed once they are added, and that adding elements must be done row-wise, and in order within each row. However, the order of rows does not matter.

Definition at line 130 of file QpSparseArray.h.

References shark::QpSparseArray< QpFloatType >::m_data, shark::QpSparseArray< QpFloatType >::m_row, shark::QpSparseArray< QpFloatType >::m_used, shark::QpSparseArray< QpFloatType >::row(), SIZE_CHECK, and shark::QpSparseArray< QpFloatType >::Entry::value.

Referenced by shark::CSvmTrainer< InputType, CacheType >::get_db_dParams().

◆ height()

template<class QpFloatType>
std::size_t shark::QpSparseArray< QpFloatType >::height ( ) const
inline

number of rows

Definition at line 101 of file QpSparseArray.h.

References shark::QpSparseArray< QpFloatType >::m_height.

Referenced by shark::QpSparseArray< QpFloatType >::resize().

◆ operator()()

◆ resize()

◆ row()

template<class QpFloatType>
Row const& shark::QpSparseArray< QpFloatType >::row ( std::size_t  row) const
inline

◆ setDefaultValue()

template<class QpFloatType>
void shark::QpSparseArray< QpFloatType >::setDefaultValue ( std::size_t  row,
QpFloatType  defaultvalue 
)
inline

set the default value, that is, the value of all implicitly defined elements of a row

Definition at line 122 of file QpSparseArray.h.

References shark::QpSparseArray< QpFloatType >::m_row, and shark::QpSparseArray< QpFloatType >::row().

Referenced by shark::CSvmTrainer< InputType, CacheType >::get_db_dParams().

◆ width()

template<class QpFloatType>
std::size_t shark::QpSparseArray< QpFloatType >::width ( ) const
inline

Member Data Documentation

◆ m_data

template<class QpFloatType>
std::vector<Entry> shark::QpSparseArray< QpFloatType >::m_data
protected

storage for Entry structures

Definition at line 164 of file QpSparseArray.h.

Referenced by shark::QpSparseArray< QpFloatType >::add(), and shark::QpSparseArray< QpFloatType >::resize().

◆ m_height

template<class QpFloatType>
std::size_t shark::QpSparseArray< QpFloatType >::m_height
protected

◆ m_row

◆ m_used

template<class QpFloatType>
std::size_t shark::QpSparseArray< QpFloatType >::m_used
protected

current total number of non-default components

Definition at line 161 of file QpSparseArray.h.

Referenced by shark::QpSparseArray< QpFloatType >::add(), and shark::QpSparseArray< QpFloatType >::resize().

◆ m_width

template<class QpFloatType>
std::size_t shark::QpSparseArray< QpFloatType >::m_width
protected

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