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 T value_type

The type of the values, the view provides access to.

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 to

  • indices – A pointer to an array of type uint32, shape (numNonZeroValues), that stores the row or column indices, the values in values correspond to

  • indptr – A pointer to an array of type uint32, shape (numCols + 1) or (numRows + 1), that stores the indices of the first element in values and indices that corresponds to a certain column, if indices stores row indices, or row, if indices stores column indices The index at the last position must be equal to numNonZeroValues

  • 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

Public Members

T *values

A pointer to the array that stores the non-zero values, the view provides access to.

T sparseValue

The value that should be used for sparse elements in the matrix.

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

typedef Matrix::view_type::value_const_iterator value_const_iterator

An iterator that provides read-only access to the values in the matrix.

typedef Matrix::view_type::value_iterator value_iterator

An iterator that provides access to the values in the matrix and allows to modify them.

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