|
Storm 1.14.0.1
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 | |
| enum class | AccumulationMode { Sum , ExpectSame , ExpectNone } |
| Specifies how values that are added for the same row and column are combined. More... | |
| 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 | setAccumulationMode (AccumulationMode mode) |
| Sets how values that are added for the same row and column are combined. | |
| AccumulationMode | getAccumulationMode () const |
| Retrieves how values that are added for the same row and column are combined. | |
| 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 134 of file SparseMatrix.h.
| typedef SparseMatrixIndexType storm::storage::SparseMatrixBuilder< ValueType >::index_type |
Definition at line 136 of file SparseMatrix.h.
| typedef ValueType storm::storage::SparseMatrixBuilder< ValueType >::value_type |
Definition at line 137 of file SparseMatrix.h.
|
strong |
Specifies how values that are added for the same row and column are combined.
Definition at line 142 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 84 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 121 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 (or addDiagonalEntry is called again for the same row), the two values are combined according to the accumulation mode (by default, we take their sum).
Definition at line 456 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. If rows are skipped entirely, the corresponding rows are treated as empty. Within a row, columns may be added in arbitrary order (the builder keeps the row sorted), but adding a column that is smaller than the previous one is slower than adding in order. If a row-column-pair is added multiple times, the values are combined according to the accumulation mode (by default, they are summed up). 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 198 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 293 of file SparseMatrix.cpp.
| SparseMatrixBuilder< ValueType >::AccumulationMode storm::storage::SparseMatrixBuilder< ValueType >::getAccumulationMode | ( | ) | const |
Retrieves how values that are added for the same row and column are combined.
Definition at line 193 of file SparseMatrix.cpp.
| SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getCurrentRowGroupCount | ( | ) | const |
Retrieves the current row group count.
Definition at line 384 of file SparseMatrix.cpp.
| SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getLastColumn | ( | ) | const |
Retrieves the most recently used row.
Definition at line 393 of file SparseMatrix.cpp.
| SparseMatrixBuilder< ValueType >::index_type storm::storage::SparseMatrixBuilder< ValueType >::getLastRow | ( | ) | const |
Retrieves the most recently used row.
Definition at line 379 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 265 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 423 of file SparseMatrix.cpp.
| void storm::storage::SparseMatrixBuilder< ValueType >::setAccumulationMode | ( | AccumulationMode | mode | ) |
Sets how values that are added for the same row and column are combined.
The default is AccumulationMode::Sum. If the mode is not AccumulationMode::Sum, adding a value that violates the mode makes addNextValue throw an InvalidArgumentException. This also applies to values added via addDiagonalEntry. The mode should be set before adding any values.
| mode | The new accumulation mode. |
Definition at line 188 of file SparseMatrix.cpp.