Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FlexibleSparseMatrix.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
8
9namespace storm {
10namespace storage {
11template<typename IndexType, typename ValueType>
12class MatrixEntry;
13
14class BitVector;
15
19template<typename ValueType>
21 public:
22 // TODO: make this class a bit more consistent with the big sparse matrix and improve it:
23 // * add stuff like iterator, clearRow, multiplyRowWithScalar
24
25 typedef uint_fast64_t index_type;
26 typedef ValueType value_type;
27 typedef std::vector<storm::storage::MatrixEntry<index_type, value_type>> row_type;
28 typedef typename row_type::iterator iterator;
29 typedef typename row_type::const_iterator const_iterator;
30
35
41
49 FlexibleSparseMatrix(storm::storage::SparseMatrix<ValueType> const& matrix, bool setAllValuesToOne = false, bool revertEquationSystem = false);
50
56 void reserveInRow(index_type row, index_type numberOfElements);
57
65
72 row_type const& getRow(index_type) const;
73
81
88 row_type const& getRow(index_type rowGroup, index_type entryInGroup) const;
89
95 std::vector<index_type> const& getRowGroupIndices() const;
96
103
110
117
124
132
140
145
150 bool empty() const;
151
158
165 void filterEntries(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint);
166
173
179
192 storm::storage::BitVector const& columnConstraint);
193
201
208 std::ostream& printRow(std::ostream& out, index_type const& rowIndex) const;
209
210 template<typename TPrime>
211 friend std::ostream& operator<<(std::ostream& out, FlexibleSparseMatrix<TPrime> const& matrix);
212
213 private:
214 std::vector<row_type> data;
215
216 // The number of columns of the matrix.
217 index_type columnCount;
218
219 // The number of entries in the matrix.
220 index_type nonzeroEntryCount;
221
222 // A flag indicating whether the matrix has a trivial row grouping. Note that this may be true and yet
223 // there may be row group indices, because they were requested from the outside.
224 bool trivialRowGrouping;
225
226 // A vector indicating the row groups of the matrix.
227 std::vector<index_type> rowGroupIndices;
228};
229} // namespace storage
230} // namespace storm
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:16
void reserveInRow(index_type row, index_type numberOfElements)
Reserves space for elements in row.
index_type getRowGroupSize(index_type group) const
Returns the size of the given row group.
index_type getColumnCount() const
Returns the number of columns of the matrix.
value_type getRowSum(index_type row) const
Computes the sum of the entries in a given row.
void updateDimensions()
Recomputes the number of columns and the number of non-zero entries.
index_type getNonzeroEntryCount() const
Returns the cached number of nonzero entries in the matrix.
std::ostream & printRow(std::ostream &out, index_type const &rowIndex) const
Print row.
std::vector< index_type > const & getRowGroupIndices() const
Returns the grouping of rows of this matrix.
storm::storage::SparseMatrix< ValueType > createSparseMatrix()
Creates a sparse matrix from the flexible sparse matrix.
row_type::const_iterator const_iterator
row_type & getRow(index_type)
Returns an object representing the given row.
bool empty() const
Checks if the matrix has no elements.
row_type & getRow(index_type rowGroup, index_type offset)
Returns an object representing the offset'th row in the rowgroup.
void filterEntries(storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint)
Erases all entries whose row and column does not satisfy the given rowConstraint and the given column...
index_type getRowCount() const
Returns the number of rows of the matrix.
FlexibleSparseMatrix()=default
Constructs an empty flexible sparse matrix.
bool hasTrivialRowGrouping() const
Retrieves whether the matrix has a (possibly) trivial row grouping.
row_type const & getRow(index_type) const
Returns an object representing the given row.
friend std::ostream & operator<<(std::ostream &out, FlexibleSparseMatrix< TPrime > const &matrix)
storm::storage::SparseMatrix< ValueType > createSparseMatrix(storm::storage::BitVector const &rowConstraint, storm::storage::BitVector const &columnConstraint)
Creates a sparse matrix from the flexible sparse matrix.
index_type insertNewRowsAtEnd(index_type numRows)
Inserts new, empty rows at the end of the FlexibleSparseMatrix.
bool rowHasDiagonalElement(storm::storage::sparse::state_type state)
Checks whether the given state has a self-loop with an arbitrary probability in the probability matri...
FlexibleSparseMatrix(index_type rows)
Constructs a flexible sparse matrix with rows many rows.
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
std::vector< storm::storage::MatrixEntry< index_type, value_type > > row_type
row_type const & getRow(index_type rowGroup, index_type entryInGroup) const
Returns an object representing the offset'th row in the rowgroup.
FlexibleSparseMatrix(storm::storage::SparseMatrix< ValueType > const &matrix, bool setAllValuesToOne=false, bool revertEquationSystem=false)
Constructs a flexible sparse matrix from a sparse matrix.
A class that holds a possibly non-square matrix in the compressed row storage format.