Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FlexibleSparseMatrix.h
Go to the documentation of this file.
1#ifndef STORM_STORAGE_FLEXIBLESPARSEMATRIX_H_
2#define STORM_STORAGE_FLEXIBLESPARSEMATRIX_H_
3
4#include <cstdint>
5#include <vector>
6
9
10namespace storm {
11namespace storage {
12template<typename IndexType, typename ValueType>
13class MatrixEntry;
14
15class BitVector;
16
20template<typename ValueType>
22 public:
23 // TODO: make this class a bit more consistent with the big sparse matrix and improve it:
24 // * add stuff like iterator, clearRow, multiplyRowWithScalar
25
26 typedef uint_fast64_t index_type;
27 typedef ValueType value_type;
28 typedef std::vector<storm::storage::MatrixEntry<index_type, value_type>> row_type;
29 typedef typename row_type::iterator iterator;
30 typedef typename row_type::const_iterator const_iterator;
31
36
42
50 FlexibleSparseMatrix(storm::storage::SparseMatrix<ValueType> const& matrix, bool setAllValuesToOne = false, bool revertEquationSystem = false);
51
57 void reserveInRow(index_type row, index_type numberOfElements);
58
66
73 row_type const& getRow(index_type) const;
74
81 row_type& getRow(index_type rowGroup, index_type offset);
82
89 row_type const& getRow(index_type rowGroup, index_type entryInGroup) const;
90
96 std::vector<index_type> const& getRowGroupIndices() const;
97
103 index_type getRowCount() const;
104
111
118
125
133
141
145 void updateDimensions();
146
151 bool empty() const;
152
158 bool hasTrivialRowGrouping() const;
159
166 void filterEntries(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint);
167
173
186 storm::storage::BitVector const& columnConstraint);
187
195
202 std::ostream& printRow(std::ostream& out, index_type const& rowIndex) const;
203
204 template<typename TPrime>
205 friend std::ostream& operator<<(std::ostream& out, FlexibleSparseMatrix<TPrime> const& matrix);
206
207 private:
208 std::vector<row_type> data;
209
210 // The number of columns of the matrix.
211 index_type columnCount;
212
213 // The number of entries in the matrix.
214 index_type nonzeroEntryCount;
215
216 // A flag indicating whether the matrix has a trivial row grouping. Note that this may be true and yet
217 // there may be row group indices, because they were requested from the outside.
218 bool trivialRowGrouping;
219
220 // A vector indicating the row groups of the matrix.
221 std::vector<index_type> rowGroupIndices;
222};
223} // namespace storage
224} // namespace storm
225
226#endif /* STORM_STORAGE_FLEXIBLESPARSEMATRIX_H_ */
A bit vector that is internally represented as a vector of 64-bit values.
Definition BitVector.h:18
The flexible sparse matrix is used during state elimination.
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 & getRow(index_type)
Returns an object representing the given row.
bool empty() const
Checks if the matrix has no elements.
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.
friend std::ostream & operator<<(std::ostream &out, FlexibleSparseMatrix< TPrime > const &matrix)
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...
index_type getRowGroupCount() const
Returns the number of row groups in the matrix.
std::vector< storm::storage::MatrixEntry< index_type, value_type > > row_type
A class that holds a possibly non-square matrix in the compressed row storage format.
storage::BitVector BitVector
LabParser.cpp.
Definition cli.cpp:18