File view_matrix_sparse_binary.hpp

class BinarySparseMatrix : public Matrix
#include <view_matrix_sparse_binary.hpp>

A two-dimensional view that provides row- or column wise access to binary values stored in a sparse matrix.

Subclassed by BinaryCscView, BinaryCsrView, SparseMatrix< T >

Public Types

typedef uint32 index_type

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

typedef View<index_type>::const_iterator index_const_iterator

An iterator that provides read-only access to the indices in the view.

typedef View<index_type>::iterator index_iterator

An iterator that provides access to the indices in the view and allows to modify them.

Public Functions

inline BinarySparseMatrix(uint32 *indices, uint32 *indptr, uint32 numRows, uint32 numCols)
Parameters:
  • indices – A pointer to an array of type uint32, shape (numNonZeroValues), that stores the row or column indices, the values in the matrix 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 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

inline BinarySparseMatrix(const BinarySparseMatrix &other)
Parameters:

other – A const reference to an object of type SparseMatrix that should be copied

inline BinarySparseMatrix(BinarySparseMatrix &&other)
Parameters:

other – A reference to an object of type SparseMatrix that should be moved

inline virtual ~BinarySparseMatrix() override
inline index_type *releaseIndices()

Releases the ownership of the array that stores the row or column indices, the non-zero values in the matrix correspond 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 the array that stores the row or column indices, the non-zero values in the matrix correspond to

inline index_type *releaseIndptr()

Releases the ownership of the array that stores the indices of the first non-zero element that corresponds to a certain column or row. 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 indices of the first non-zero element that corresponds to a certain column or row

Public Members

uint32 *indices

A pointer to an array that stores the row or column indices, the values in the matrix correspond to.

uint32 *indptr

A pointer to an array that stores the indices of the first element in indices that corresponds to a certain column, if indices stores row indices, or row, if indices stores column indices.

template<typename Matrix>
class IterableBinarySparseMatrixDecorator : public Matrix
#include <view_matrix_sparse_binary.hpp>

Provides row- or column-wise access via iterators to the indices stored in a sparse matrix.

Template Parameters:

Matrix – The type of the matrix

Subclassed by IterableSparseMatrixDecorator< Matrix >

Public Types

typedef Matrix::view_type::index_const_iterator index_const_iterator

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

typedef Matrix::view_type::index_iterator index_iterator

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

Public Functions

inline IterableBinarySparseMatrixDecorator(typename Matrix::view_type &&view)
Parameters:

view – The view, the matrix should be backed by

inline virtual ~IterableBinarySparseMatrixDecorator() override
inline index_const_iterator indices_cbegin(uint32 index) const

Returns an index_const_iterator to the beginning of the indices 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:

An index_const_iterator to the beginning of the indices

inline index_const_iterator indices_cend(uint32 index) const

Returns an index_const_iterator to the end of the indices 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:

An index_const_iterator to the end of the indices

inline index_iterator indices_begin(uint32 index)

Returns an index_iterator to the beginning of the indices 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:

An index_iterator to the beginning of the indices

inline index_iterator indices_end(uint32 index)

Returns an index_iterator to the end of the indices 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:

An index_iterator to the end of the indices

inline uint32 getNumNonZeroElements() const

Returns the number of non-zero elements in the matrix.

Returns:

The number of non-zero elements