Storm
A Modern Probabilistic Model Checker
|
A class that can be used to build a sparse matrix by adding value by value. More...
#include <SparseMatrix.h>
Public Types | |
typedef SparseMatrixIndexType | index_type |
typedef ValueType | value_type |
Public Member Functions | |
SparseMatrixBuilder (index_type rows=0, index_type columns=0, index_type entries=0, bool forceDimensions=true, bool hasCustomRowGrouping=false, index_type rowGroups=0) | |
Constructs a sparse matrix builder producing a matrix with the given number of rows, columns and entries. | |
SparseMatrixBuilder (SparseMatrix< ValueType > &&matrix) | |
Moves the contents of the given matrix into the matrix builder so that its contents can be modified again. | |
void | addNextValue (index_type row, index_type column, value_type const &value) |
Sets the matrix entry at the given row and column to the given value. | |
void | newRowGroup (index_type startingRow) |
Starts a new row group in the matrix. | |
SparseMatrix< value_type > | build (index_type overriddenRowCount=0, index_type overriddenColumnCount=0, index_type overriddenRowGroupCount=0) |
index_type | getLastRow () const |
Retrieves the most recently used row. | |
index_type | getCurrentRowGroupCount () const |
Retrieves the current row group count. | |
index_type | getLastColumn () const |
Retrieves the most recently used row. | |
void | replaceColumns (std::vector< index_type > const &replacements, index_type offset) |
Replaces all columns with id > offset according to replacements. | |
void | addDiagonalEntry (index_type row, ValueType const &value) |
Makes sure that a diagonal entry will be inserted at the given row. | |
A class that can be used to build a sparse matrix by adding value by value.
Definition at line 137 of file SparseMatrix.h.
typedef SparseMatrixIndexType storm::storage::SparseMatrixBuilder< ValueType >::index_type |
Definition at line 139 of file SparseMatrix.h.
typedef ValueType storm::storage::SparseMatrixBuilder< ValueType >::value_type |
Definition at line 140 of file SparseMatrix.h.
storm::storage::SparseMatrixBuilder< ValueType >::SparseMatrixBuilder | ( | index_type | rows = 0 , |
index_type | columns = 0 , |
||
index_type | entries = 0 , |
||
bool | forceDimensions = true , |
||
bool | hasCustomRowGrouping = false , |
||
index_type | rowGroups = 0 |
||
) |
Constructs a sparse matrix builder producing a matrix with the given number of rows, columns and entries.
The number of rows, columns and entries is reserved upon creation. If more rows/columns or entries are added, this will possibly lead to a reallocation.
rows | The number of rows of the resulting matrix. |
columns | The number of columns of the resulting matrix. |
entries | The number of entries of the resulting matrix. |
forceDimensions | If this flag is set, the matrix is expected to have exactly the given number of rows, columns and entries for all of these entities that are set to a nonzero value. |
hasCustomRowGrouping | A flag indicating whether the builder is used to create a non-canonical grouping of rows for this matrix. |
rowGroups | The number of row groups of the resulting matrix. This is only relevant if the matrix has a custom row grouping. |
Definition at line 83 of file SparseMatrix.cpp.
storm::storage::SparseMatrixBuilder< ValueType >::SparseMatrixBuilder | ( | SparseMatrix< ValueType > && | matrix | ) |
Moves the contents of the given matrix into the matrix builder so that its contents can be modified again.
This is, for example, useful if rows need to be added to the matrix.
matrix | The matrix that is to be made editable again. |
Definition at line 120 of file SparseMatrix.cpp.
void storm::storage::SparseMatrixBuilder< ValueType >::addDiagonalEntry | ( | index_type | row, |
ValueType const & | value | ||
) |
Makes sure that a diagonal entry will be inserted at the given row.
All other entries of this row must be set immediately after calling this (without setting values at other rows in between) The provided row must not be smaller than the row of the most recent insertion. If there is a row grouping, the column of the diagonal entry will correspond to the current row group. If addNextValue is called on the given row and the diagonal column, we take the sum of the two values provided to addDiagonalEntry and addNextValue
Definition at line 432 of file SparseMatrix.cpp.
void storm::storage::SparseMatrixBuilder< ValueType >::addNextValue | ( | index_type | row, |
index_type | column, | ||
value_type const & | value | ||
) |
Sets the matrix entry at the given row and column to the given value.
After all entries have been added, a call to finalize(false) is mandatory.
Note: this is a linear setter. That is, it must be called consecutively for each entry, row by row and column by column. As multiple entries per column are admitted, consecutive calls to this method are admitted to mention the same row-column-pair. If rows are skipped entirely, the corresponding rows are treated as empty. If these constraints are not met, an exception is thrown.
row | The row in which the matrix entry is to be set. |
column | The column in which the matrix entry is to be set. |
value | The value that is to be set at the specified row and column. |
Definition at line 156 of file SparseMatrix.cpp.
SparseMatrix< ValueType > storm::storage::SparseMatrixBuilder< ValueType >::build | ( | index_type | overriddenRowCount = 0 , |
index_type | overriddenColumnCount = 0 , |
||
index_type | overriddenRowGroupCount = 0 |
||
) |
Definition at line 281 of file SparseMatrix.cpp.
SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getCurrentRowGroupCount | ( | ) | const |
Retrieves the current row group count.
Definition at line 361 of file SparseMatrix.cpp.
SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getLastColumn | ( | ) | const |
Retrieves the most recently used row.
Definition at line 370 of file SparseMatrix.cpp.
SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getLastRow | ( | ) | const |
Retrieves the most recently used row.
Definition at line 356 of file SparseMatrix.cpp.
void storm::storage::SparseMatrixBuilder< ValueType >::newRowGroup | ( | index_type | startingRow | ) |
Starts a new row group in the matrix.
Note that this needs to be called before any entries in the new row group are added.
startingRow | The starting row of the new row group. |
Definition at line 253 of file SparseMatrix.cpp.
void storm::storage::SparseMatrixBuilder< ValueType >::replaceColumns | ( | std::vector< index_type > const & | replacements, |
index_type | offset | ||
) |
Replaces all columns with id > offset according to replacements.
Every state with id offset+i is replaced by the id in replacements[i]. Afterwards the columns are sorted.
replacements | Mapping indicating the replacements from offset+i -> value of i. |
offset | Offset to add to each id in vector index. |
Definition at line 399 of file SparseMatrix.cpp.