From a40d12f9153bd8e0c0917120b8966819db20791c Mon Sep 17 00:00:00 2001 From: dehnert Date: Tue, 8 Mar 2016 08:48:41 +0100 Subject: [PATCH] made getRowGroup more consistent and fixed some introduced bugs Former-commit-id: 99b6c0e3a5b5d263c185fbd4bdb08d435c5b688b --- src/storage/SparseMatrix.cpp | 14 +++++++------- src/storage/SparseMatrix.h | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index df78e4e2d..99e21ee0d 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -1067,22 +1067,22 @@ namespace storm { template typename SparseMatrix::const_rows SparseMatrix::getRows(index_type startRow, index_type endRow) const { - return const_rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow + 1] - this->rowIndications[startRow]); + return const_rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow] - this->rowIndications[startRow]); } template typename SparseMatrix::rows SparseMatrix::getRows(index_type startRow, index_type endRow) { - return rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow + 1] - this->rowIndications[startRow]); + return rows(this->columnsAndValues.begin() + this->rowIndications[startRow], this->rowIndications[endRow] - this->rowIndications[startRow]); } template typename SparseMatrix::const_rows SparseMatrix::getRow(index_type row) const { - return getRows(row, row); + return getRows(row, row + 1); } template typename SparseMatrix::rows SparseMatrix::getRow(index_type row) { - return getRows(row, row); + return getRows(row, row + 1); } template @@ -1096,7 +1096,6 @@ namespace storm { } } - template typename SparseMatrix::rows SparseMatrix::getRow(index_type rowGroup, index_type offset) { STORM_LOG_ASSERT(rowGroup < this->getRowGroupCount(), "Row group is out-of-bounds."); @@ -1104,6 +1103,7 @@ namespace storm { if (!this->hasTrivialRowGrouping()) { return getRow(this->getRowGroupIndices()[rowGroup] + offset); } else { + STORM_LOG_ASSERT(offset == 0, "Invalid offset."); return getRow(rowGroup + offset); } } @@ -1113,7 +1113,7 @@ namespace storm { typename SparseMatrix::const_rows SparseMatrix::getRowGroup(index_type rowGroup) const { STORM_LOG_ASSERT(rowGroup < this->getRowGroupCount(), "Row group is out-of-bounds."); if (!this->hasTrivialRowGrouping()) { - return getRows(this->getRowGroupIndices()[rowGroup], this->getRowGroupIndices()[rowGroup + 1] - 1); + return getRows(this->getRowGroupIndices()[rowGroup], this->getRowGroupIndices()[rowGroup + 1]); } else { return getRows(rowGroup, rowGroup + 1); } @@ -1123,7 +1123,7 @@ namespace storm { typename SparseMatrix::rows SparseMatrix::getRowGroup(index_type rowGroup) { STORM_LOG_ASSERT(rowGroup < this->getRowGroupCount(), "Row group is out-of-bounds."); if (!this->hasTrivialRowGrouping()) { - return getRows(this->getRowGroupIndices()[rowGroup], this->getRowGroupIndices()[rowGroup + 1] - 1); + return getRows(this->getRowGroupIndices()[rowGroup], this->getRowGroupIndices()[rowGroup + 1]); } else { return getRows(rowGroup, rowGroup + 1); } diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 730e018f2..c5c7133c6 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -805,7 +805,7 @@ namespace storm { * Returns an object representing the consecutive rows given by the parameters. * * @param startRow The starting row. - * @param endRow The ending row (which is included in the result). + * @param endRow The ending row (which is *not* included in the result). * @return An object representing the consecutive rows given by the parameters. */ const_rows getRows(index_type startRow, index_type endRow) const; @@ -814,7 +814,7 @@ namespace storm { * Returns an object representing the consecutive rows given by the parameters. * * @param startRow The starting row. - * @param endRow The ending row (which is included in the result). + * @param endRow The ending row (which is *not* included in the result). * @return An object representing the consecutive rows given by the parameters. */ rows getRows(index_type startRow, index_type endRow);