File view_matrix_sparse.hpp¶
-
template<typename T>
class SparseMatrix : public BinarySparseMatrix¶ - #include <view_matrix_sparse.hpp>
A two-dimensional view that provides row-or column wise access to values stored in a sparse matrix.
- Template Parameters:
T – The type of the values, the view provides access to
Subclassed by CscView< T >, CsrView< T >
Public Types
-
typedef View<value_type>::const_iterator value_const_iterator¶
An iterator that provides read-only access to the values in the view.
-
typedef View<value_type>::iterator value_iterator¶
An iterator that provides access to the values in the view and allows to modify them.
Public Functions
-
inline SparseMatrix(T *values, uint32 *indices, uint32 *indptr, uint32 numRows, uint32 numCols, T sparseValue)¶
- Parameters:
values – A pointer to an array of template type
T
that stores all non-zero values, the view should provide access toindices – A pointer to an array of type
uint32
, shape(numNonZeroValues)
, that stores the row or column indices, the values invalues
correspond toindptr – A pointer to an array of type
uint32
, shape(numCols + 1)
or(numRows + 1)
, that stores the indices of the first element invalues
andindices
that corresponds to a certain column, ifindices
stores row indices, or row, ifindices
stores column indices The index at the last position must be equal tonumNonZeroValues
numRows – The number of rows in the view
numCols – The number of columns in the view
sparseValue – The value that should be used for sparse elements in the matrix
-
inline SparseMatrix(const SparseMatrix<T> &other)¶
- Parameters:
other – A const reference to an object of type
SparseMatrix
that should be copied
-
inline SparseMatrix(SparseMatrix<T> &&other)¶
- Parameters:
other – A reference to an object of type
SparseMatrix
that should be moved
-
inline virtual ~SparseMatrix() override¶
-
inline value_type *releaseValues()¶
Releases the ownership of the array that stores the non-zero values, the view provides access to. As a result, the behavior of this view becomes undefined and it should not be used anymore. The caller is responsible for freeing the memory that is occupied by the array.
- Returns:
A pointer to an array that stores the non-zero values, the view provides access to
-
template<typename Matrix>
class IterableSparseMatrixDecorator : public IterableBinarySparseMatrixDecorator<Matrix>¶ - #include <view_matrix_sparse.hpp>
Provides row- or column-wise access via iterators to the indices and values stored in a sparse matrix.
- Template Parameters:
Matrix – The type of the matrix
Public Types
Public Functions
-
inline IterableSparseMatrixDecorator(typename Matrix::view_type &&view)¶
- Parameters:
view – The view, the matrix should be backed by
-
inline virtual ~IterableSparseMatrixDecorator() override¶
-
inline value_const_iterator values_cbegin(uint32 index) const¶
Returns a
value_const_iterator
to the beginning of the values in a specific row or column of the matrix, depending on the memory layout of the view, the matrix is backed by.- Parameters:
index – The index of the row or column
- Returns:
A
value_const_iterator
to the beginning of the values
-
inline value_const_iterator values_cend(uint32 index) const¶
Returns a
value_const_iterator
to the end of the values in a specific row or column of the matrix, depending on the memory layout of the view, the matrix is backed by.- Parameters:
index – The index of the row or column
- Returns:
A
value_const_iterator
to the end of the values
-
inline value_iterator values_begin(uint32 index)¶
Returns a
value_iterator
to the beginning of the values in a specific row or column of the matrix, depending on the memory layout of the view, the matrix is backed by.- Parameters:
index – The index of the row or column
- Returns:
A
value_iterator
to the beginning of the values
-
inline value_iterator values_end(uint32 index)¶
Returns a
value_iterator
to the end of the values in a specific row or column of the matrix, depending on the memory layout of the view, the matrix is backed by.- Parameters:
index – The index of the row or column
- Returns:
A
value_iterator
to the end of the values