diff --git a/src/storage/FlexibleSparseMatrix.cpp b/src/storage/FlexibleSparseMatrix.cpp index 10cda2ab2..81e87ce20 100644 --- a/src/storage/FlexibleSparseMatrix.cpp +++ b/src/storage/FlexibleSparseMatrix.cpp @@ -13,7 +13,13 @@ namespace storm { } template - FlexibleSparseMatrix::FlexibleSparseMatrix(storm::storage::SparseMatrix const& matrix, bool setAllValuesToOne) : data(matrix.getRowCount()), columnCount(matrix.getColumnCount()), nonzeroEntryCount(matrix.getNonzeroEntryCount()) { + FlexibleSparseMatrix::FlexibleSparseMatrix(storm::storage::SparseMatrix const& matrix, bool setAllValuesToOne) : data(matrix.getRowCount()), columnCount(matrix.getColumnCount()), nonzeroEntryCount(matrix.getNonzeroEntryCount()), nontrivialRowGrouping(matrix.hasNontrivialRowGrouping()) { + if (nontrivialRowGrouping) { + rowGroupIndices = matrix.getRowGroupIndices(); + rowIndications = matrix.getRowIndications(); + // Not fully implemented yet + assert(false); + } for (index_type rowIndex = 0; rowIndex < matrix.getRowCount(); ++rowIndex) { typename storm::storage::SparseMatrix::const_rows row = matrix.getRow(rowIndex); reserveInRow(rowIndex, row.getNumberOfEntries()); @@ -83,6 +89,11 @@ namespace storm { } return true; } + + template + bool SparseMatrix::hasNontrivialRowGrouping() const { + return nontrivialRowGrouping; + } template void FlexibleSparseMatrix::createSubmatrix(storm::storage::BitVector const& rowConstraint, storm::storage::BitVector const& columnConstraint) { diff --git a/src/storage/FlexibleSparseMatrix.h b/src/storage/FlexibleSparseMatrix.h index e6ac6c97d..295b0337b 100644 --- a/src/storage/FlexibleSparseMatrix.h +++ b/src/storage/FlexibleSparseMatrix.h @@ -23,6 +23,7 @@ namespace storm { // TODO: make this class a bit more consistent with the big sparse matrix and improve it: // * add output iterator and improve the way the matrix is printed // * add stuff like clearRow, multiplyRowWithScalar + // * implement row grouping typedef uint_fast64_t index_type; typedef ValueType value_type; @@ -102,6 +103,13 @@ namespace storm { * @return True, if the matrix is empty. */ bool empty() const; + + /*! + * Retrieves whether the matrix has a (possibly) non-trivial row grouping. + * + * @return True iff the matrix has a (possibly) non-trivial row grouping. + */ + bool hasNontrivialRowGrouping() const; /*! * Creates a submatrix of the current matrix in place by dropping all rows and columns whose bits are not @@ -137,6 +145,17 @@ namespace storm { // The number of entries in the matrix. index_type nonzeroEntryCount; + + // A vector containing the indices at which each given row begins. The values of the entries in row i are + // data[rowIndications[i]] to data[rowIndications[i + 1]] where the last entry is not included anymore. + std::vector rowIndications; + + // A flag that indicates whether the matrix has a non-trivial row-grouping, i.e. (possibly) more than one + // row per row group. + bool nontrivialRowGrouping; + + // A vector indicating the row groups of the matrix. + std::vector rowGroupIndices; }; } } diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index 253609210..04e941561 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -451,6 +451,11 @@ namespace storm { std::vector::index_type> const& SparseMatrix::getRowGroupIndices() const { return rowGroupIndices; } + + template + std::vector::index_type> const& SparseMatrix::getRowIndications() const { + return rowIndications; + } template void SparseMatrix::makeRowsAbsorbing(storm::storage::BitVector const& rows) { diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index f9d9916c4..94defdfa5 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -549,6 +549,13 @@ namespace storm { */ std::vector const& getRowGroupIndices() const; + /*! + * Returns the indices where new row groups start. + * + * @return The indices where new row groups start. + */ + std::vector const& getRowIndications() const; + /*! * This function makes the given rows absorbing. *