File view_matrix_sparse_set.hpp

template<typename T>
class SparseSetView : public CompositeMatrix<AllocatedListOfLists<IndexedValue<T>>, AllocatedCContiguousView<uint32>>
#include <view_matrix_sparse_set.hpp>

A two-dimensional view that provides random read and write access, as well as row-wise read and write access via iterators, to values stored in a sparse matrix in the list of lists (LIL) format. Compared to the view ListOfLists, the ability to provide random access to the elements in the view comes at the expense of memory efficiency, as it does not only require to maintain a sparse matrix, but also a dense matrix that stores for each element the corresponding position in the sparse matrix, if available.

The data structure that is used for the representation of a single row is often referred to as an “unordered sparse

set”. It was originally proposed in “An efficient representation for sparse sets”, Briggs, Torczon, 1993.

Template Parameters:

T – The type of the values, the view provides access to

Public Types

using value_type = AllocatedListOfLists<IndexedValue<T>>::value_type

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

using value_const_iterator = AllocatedListOfLists<IndexedValue<T>>::value_const_iterator

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

using value_iterator = AllocatedListOfLists<IndexedValue<T>>::value_iterator

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

using const_row = const SparseSetVector<T, const std::vector<IndexedValue<T>>, const uint32>

Provides read-only access to an individual row in the view.

using row = SparseSetVector<T>

Provides access to an individual row in the view and allows to modify it.

Public Functions

inline SparseSetView(uint32 numRows, uint32 numCols)
Parameters:
  • numRows – The number of rows in the view

  • numCols – The number of columns in the view

inline SparseSetView(SparseSetView &&other)
Parameters:

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

inline virtual ~SparseSetView() override
inline const_row operator[](uint32 row) const

Creates and returns a view that provides read-only access to a specific row in the view.

Parameters:

row – The index of the row

Returns:

A const_row

inline row operator[](uint32 row)

Creates and returns a view that provides access to a specific row in the view and allows to modify it.

Parameters:

row – The index of the row

Returns:

A row

inline value_const_iterator values_cbegin(uint32 row) const

Returns a value_const_iterator to the beginning of the values in a specific row of the view.

Parameters:

row – The index of the row

Returns:

A value_const_iterator to the beginning of the values

inline value_const_iterator values_cend(uint32 row) const

Returns a value_const_iterator to the end of the values in a specific row of the view.

Parameters:

row – The index of the row

Returns:

A value_const_iterator to the end of the values

inline value_iterator values_begin(uint32 row)

Returns a value_iterator to the beginning of the values in a specific row of the view.

Parameters:

row – The index of the row

Returns:

A value_iterator to the beginning of the values

inline value_iterator values_end(uint32 row)

Returns a value_iterator to the end of the values in a specific row of the view.

Parameters:

row – The index of the row

Returns:

A value_iterator to the end of the values

inline void clear()

Sets all values stored in the matrix to zero.

Public Static Attributes

static uint32 MAX_INDEX = SparseSetVector<T>::MAX_INDEX

The index that is used to indicate that the value at a specific row and column is zero.

template<typename Matrix>
class IterableSparseSetViewDecorator : public Matrix
#include <view_matrix_sparse_set.hpp>

Provides random read and write access, as well as row-wise read and write access via iterators, to values stored in a sparse matrix in the list of lists (LIL) format.

Template Parameters:

Matrix – The type of the matrix

Public Types

using value_const_iterator = Matrix::view_type::value_const_iterator

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

using value_iterator = Matrix::view_type::value_iterator

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

using const_row = Matrix::view_type::const_row

Provides read-only access to an individual row in the matrix.

using row = Matrix::view_type::row

Provides access to an individual row in the matrix and allows to modify it.

Public Functions

inline explicit IterableSparseSetViewDecorator(typename Matrix::view_type &&view)
Parameters:

view – The view, the matrix should be backed by

inline virtual ~IterableSparseSetViewDecorator() override
inline const_row operator[](uint32 row) const

Creates and returns a view that provides read-only access to a specific row in the matrix.

Parameters:

row – The index of the row

Returns:

A const_row

inline row operator[](uint32 row)

Creates and returns a view that provides access to a specific row in the matrix and allows to modify it.

Parameters:

row – The index of the row

Returns:

A row

inline value_const_iterator values_cbegin(uint32 row) const

Returns a value_const_iterator to the beginning of the values in a specific row of the matrix.

Parameters:

row – The index of the row

Returns:

A value_const_iterator to the beginning of the values

inline value_const_iterator values_cend(uint32 row) const

Returns a value_const_iterator to the end of the values in a specific row of the matrix.

Parameters:

row – The index of the row

Returns:

A value_const_iterator to the end of the values

inline value_iterator values_begin(uint32 row)

Returns a value_iterator to the beginning of the values in a specific row of the matrix.

Parameters:

row – The index of the row

Returns:

A value_iterator to the beginning of the values

inline value_iterator values_end(uint32 row)

Returns a value_iterator to the end of the values in a specific row of the matrix.

Parameters:

row – The index of the row

Returns:

A value_iterator to the end of the values