25#ifndef _GEMA_SPARSE_MATRIX_LAYOUT_H_
26#define _GEMA_SPARSE_MATRIX_LAYOUT_H_
34#define ENABLE_MATRIX_LAYOUT_INDEX_CACHE 1
37#ifdef ENABLE_MATRIX_LAYOUT_INDEX_CACHE
83 virtual int index(
int row,
int col)
const = 0;
102 virtual void checkLayoutData()
const = 0;
122template <
class IndexType, GmSparseMatrixLayoutTypes T>
133 _ptr = _index = NULL;
137#ifdef ENABLE_MATRIX_LAYOUT_INDEX_CACHE
150 virtual bool empty()
const {
return _n == 0; }
157 _ptr = _index = NULL;
160#ifdef ENABLE_MATRIX_LAYOUT_INDEX_CACHE
168 virtual int index(
int row,
int col)
const;
171 virtual int dindex(
int n)
const {
return indexWorker(_ptr[n], _ptr[n+1], n); }
173 virtual void printStatistics(
const GmLogCategory& logger)
const;
176 virtual void checkLayoutData()
const;
185#ifdef ENABLE_MATRIX_LAYOUT_INDEX_CACHE
190 inline int indexWorker(
int start,
int end,
int ind)
const;
Class representing a category with multiple logging levels.
Definition gmLog.h:58
A class that works together with GmThreadManager to provide thread local storage.
Definition gmThreadLocalStorage.h:132
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
GmCSxSparseMatrixLayout< int, GM_CSR_SPARSE_FORMAT > GmCSRSparseMatrixLayout
CSR layout with 32 bits integer index.
Definition gmSparseMatrixLayout.h:202
GmCSxSparseMatrixLayout< arma::uword, GM_CSR_SPARSE_FORMAT > GmCSRArmadilloSparseMatrixLayout
CSR layout with 64 bits integer index.
Definition gmSparseMatrixLayout.h:205
GmCSxSparseMatrixLayout< int, GM_CSC_SPARSE_FORMAT > GmCSCSparseMatrixLayout
CSC layout with 32 bits integer index.
Definition gmSparseMatrixLayout.h:208
GmSparseMatrixLayoutTypes
Supported sparse matrix types by GmSparseMatrixLayout sub-classes.
Definition gmSparseMatrixLayout.h:46
@ GM_CSC_SPARSE_FORMAT
Data is stored in "Compressed Sparse Column" format.
Definition gmSparseMatrixLayout.h:47
@ GM_CSR_SPARSE_FORMAT
Data is stored in "Compressed Sparse Row" (or old Yale) format.
Definition gmSparseMatrixLayout.h:48
GmCSxSparseMatrixLayout< arma::uword, GM_CSC_SPARSE_FORMAT > GmCSCArmadilloSparseMatrixLayout
CSC layout with 64 bits integer index.
Definition gmSparseMatrixLayout.h:211
Declaration of the GmTLS class.
A structure for storing a matrix layout in either CSR or CSC format. The template type defines the ty...
Definition gmSparseMatrixLayout.h:124
IndexType * _ptr
Vector storing the index of the first non zero element of each matrix row(CSR)/column(CSC)....
Definition gmSparseMatrixLayout.h:179
virtual bool empty() const
Returns true if the layout is empty.
Definition gmSparseMatrixLayout.h:150
int _arma
Stores 1 if the layout should store 1 extra space per vector to be compatible with Armadillo requirem...
Definition gmSparseMatrixLayout.h:183
virtual int index(int row, int col) const
Returns the index for the value in the given matrix row, col. Returns -1 if the value is not part of ...
GmCSxSparseMatrixLayout(bool arma)
Constructor.
Definition gmSparseMatrixLayout.h:131
virtual int dindex(int n) const
Returns the index for the value in the diagonal of the given matrix row (column). Returns -1 if the v...
Definition gmSparseMatrixLayout.h:171
int _n
The number of rows(CSR)/columns(CSC) in the matrix.
Definition gmSparseMatrixLayout.h:181
virtual void clear()
Clears the layout releasing memory and making the matrix a zero matrix.
Definition gmSparseMatrixLayout.h:153
IndexType * _index
Vector storing the column(CSR)/row(CSC) index for each non zero value. Size = _nnz.
Definition gmSparseMatrixLayout.h:180
int _nnz
The number of elements stored in the matrix (in some cases zero values can be stored,...
Definition gmSparseMatrixLayout.h:182
virtual ~GmCSxSparseMatrixLayout()
Destructor.
Definition gmSparseMatrixLayout.h:143
A base structure for storing layout data for sparse matrices (fill structure or non zero positions)....
Definition gmSparseMatrixLayout.h:66
virtual bool empty() const =0
Returns true if the layout is empty.
GmSparseMatrixLayoutTypes _type
The stored sparse matrix type.
Definition gmSparseMatrixLayout.h:98
void emitLayoutCompleted()
Emits the layoutCompleted signal.
Definition gmSparseMatrixLayout.h:96
virtual int dindex(int n) const =0
Returns the index for the value in the diagonal of the given matrix row (column). Returns -1 if the v...
void layoutCompleted()
A signal emitted when the layout has been completed. This signal is emitted on behalf of the layout b...
virtual ~GmSparseMatrixLayout()
Virtual destructor.
Definition gmSparseMatrixLayout.h:74
GmSparseMatrixLayout(GmSparseMatrixLayoutTypes type)
Constructor.
Definition gmSparseMatrixLayout.h:71
virtual void printStatistics(const GmLogCategory &logger) const =0
Print layout statistics to the given logger.
bool _shared
Is this layout shared? Mutable to enable matrices sharing a layout to specify so.
Definition gmSparseMatrixLayout.h:99
virtual void clear()=0
Clears the layout releasing memory and making the matrix a zero matrix.
virtual int index(int row, int col) const =0
Returns the index for the value in the given matrix row, col. Returns -1 if the value is not part of ...