Efficient quadratic matrix cache. More...
#include <shark/LinAlg/CachedMatrix.h>
Public Types | |
typedef Matrix::QpFloatType | QpFloatType |
Public Member Functions | |
CachedMatrix (Matrix *base, std::size_t cachesize=0x4000000) | |
void | row (std::size_t k, std::size_t start, std::size_t end, QpFloatType *storage) const |
Copies the range [start,end) of the k-th row of the matrix in external storage. More... | |
QpFloatType * | row (std::size_t k, std::size_t start, std::size_t end) |
Return a subset of a matrix row. 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 | flipColumnsAndRows (std::size_t i, std::size_t j) |
Swap the rows i and j and the columns i and j. More... | |
std::size_t | size () const |
return the size of the quadratic matrix More... | |
std::size_t | getMaxCacheSize () const |
return the size of the kernel cache (in "number of QpFloatType-s") More... | |
std::size_t | getCacheSize () const |
get currently used size of kernel cache (in "number of QpFloatType-s") More... | |
std::size_t | getCacheRowSize (std::size_t k) const |
get length of one specific currently cached row More... | |
bool | isCached (std::size_t k) const |
void | setMaxCachedIndex (std::size_t n) |
Restrict the cached part of the matrix to the upper left nxn sub-matrix. More... | |
void | clear () |
completely clear/purge the kernel cache More... | |
Protected Attributes | |
Matrix * | mep_baseMatrix |
matrix to be cached More... | |
LRUCache< QpFloatType > | m_cache |
cache of the matrix lines More... | |
Efficient quadratic matrix cache.
Definition at line 157 of file CachedMatrix.h.
typedef Matrix::QpFloatType shark::CachedMatrix< Matrix >::QpFloatType |
Definition at line 160 of file CachedMatrix.h.
|
inline |
Constructor
base | Matrix to cache |
cachesize | Main memory to use as a kernel cache, in QpFloatTypes. Default is 256MB if QpFloatType is float, 512 if double. |
Definition at line 165 of file CachedMatrix.h.
|
inline |
completely clear/purge the kernel cache
Definition at line 287 of file CachedMatrix.h.
References shark::LRUCache< T >::clear(), and shark::CachedMatrix< Matrix >::m_cache.
|
inline |
return a single matrix entry
Definition at line 214 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::mep_baseMatrix.
Referenced by shark::CachedMatrix< Matrix >::operator()().
|
inline |
Swap the rows i and j and the columns i and j.
i | first row/column index |
j | second row/column index |
Definition at line 230 of file CachedMatrix.h.
References shark::LRUCache< T >::getLinePointer(), shark::LRUCache< T >::lineLength(), shark::CachedMatrix< Matrix >::m_cache, shark::CachedMatrix< Matrix >::mep_baseMatrix, shark::CachedMatrix< Matrix >::size(), shark::swap(), and shark::LRUCache< T >::swapLineIndices().
|
inline |
get length of one specific currently cached row
Definition at line 265 of file CachedMatrix.h.
References shark::LRUCache< T >::lineLength(), and shark::CachedMatrix< Matrix >::m_cache.
|
inline |
get currently used size of kernel cache (in "number of QpFloatType-s")
Definition at line 261 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::m_cache, and shark::LRUCache< T >::size().
|
inline |
return the size of the kernel cache (in "number of QpFloatType-s")
Definition at line 257 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::m_cache, and shark::LRUCache< T >::maxSize().
|
inline |
Definition at line 268 of file CachedMatrix.h.
References shark::LRUCache< T >::isCached(), and shark::CachedMatrix< Matrix >::m_cache.
|
inline |
return a single matrix entry
Definition at line 209 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::entry().
|
inline |
Copies the range [start,end) of the k-th row of the matrix in external storage.
This call regards the access to the line as out-of-order, thus the cache is not influenced.
k | the index of the row |
start | the index of the first element in the range |
end | the index of the last element in the range |
storage | the external storage. must be big enough capable to hold the range |
Definition at line 175 of file CachedMatrix.h.
References shark::LRUCache< T >::getLinePointer(), shark::LRUCache< T >::lineLength(), shark::CachedMatrix< Matrix >::m_cache, shark::CachedMatrix< Matrix >::mep_baseMatrix, shark::CachedMatrix< Matrix >::size(), and SIZE_CHECK.
|
inline |
Return a subset of a matrix row.
k | matrix row |
start | first column to be filled in |
end | last column to be filled in +1 |
Definition at line 197 of file CachedMatrix.h.
References shark::LRUCache< T >::getCacheLine(), shark::LRUCache< T >::lineLength(), shark::CachedMatrix< Matrix >::m_cache, and shark::CachedMatrix< Matrix >::mep_baseMatrix.
|
inline |
Restrict the cached part of the matrix to the upper left nxn sub-matrix.
Definition at line 272 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::m_cache, shark::LRUCache< T >::markLineForDeletion(), shark::CachedMatrix< Matrix >::size(), and SIZE_CHECK.
|
inline |
return the size of the quadratic matrix
Definition at line 253 of file CachedMatrix.h.
References shark::CachedMatrix< Matrix >::mep_baseMatrix.
Referenced by shark::CachedMatrix< Matrix >::flipColumnsAndRows(), shark::CachedMatrix< Matrix >::row(), and shark::CachedMatrix< Matrix >::setMaxCachedIndex().
|
protected |
cache of the matrix lines
Definition at line 293 of file CachedMatrix.h.
Referenced by shark::CachedMatrix< Matrix >::clear(), shark::CachedMatrix< Matrix >::flipColumnsAndRows(), shark::CachedMatrix< Matrix >::getCacheRowSize(), shark::CachedMatrix< Matrix >::getCacheSize(), shark::CachedMatrix< Matrix >::getMaxCacheSize(), shark::CachedMatrix< Matrix >::isCached(), shark::CachedMatrix< Matrix >::row(), and shark::CachedMatrix< Matrix >::setMaxCachedIndex().
|
protected |
matrix to be cached
Definition at line 291 of file CachedMatrix.h.
Referenced by shark::CachedMatrix< Matrix >::entry(), shark::CachedMatrix< Matrix >::flipColumnsAndRows(), shark::CachedMatrix< Matrix >::row(), and shark::CachedMatrix< Matrix >::size().