From 90fa8f6f0df989c924be91784d4b992c763df72a Mon Sep 17 00:00:00 2001 From: sjunges Date: Mon, 10 Aug 2015 18:34:58 +0200 Subject: [PATCH] convenience methods for sparse matrix added Former-commit-id: 3feda8a8c30b99cbc708ce0c7a1b1e754c07b6d0 --- src/storage/SparseMatrix.cpp | 18 ++++++++++++++++++ src/storage/SparseMatrix.h | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/storage/SparseMatrix.cpp b/src/storage/SparseMatrix.cpp index 2cb9f995b..eb86e1f22 100644 --- a/src/storage/SparseMatrix.cpp +++ b/src/storage/SparseMatrix.cpp @@ -987,13 +987,31 @@ namespace storm { return getRows(row, row); } + template + typename SparseMatrix::const_rows SparseMatrix::getRow(index_type rowGroup, index_type offset) const { + assert(rowGroup < this->getRowGroupCount()); + assert(offset < this->getRowGroupEntryCount(rowGroup)); + return getRow(rowGroupIndices[rowGroup] + offset); + } + + + template + typename SparseMatrix::rows SparseMatrix::getRow(index_type rowGroup, index_type offset) { + assert(rowGroup < this->getRowGroupCount()); + assert(offset < this->getRowGroupEntryCount(rowGroup)); + return getRow(rowGroupIndices[rowGroup] + offset); + } + + template typename SparseMatrix::const_rows SparseMatrix::getRowGroup(index_type rowGroup) const { + assert(rowGroup < this->getRowGroupCount()); return getRows(rowGroupIndices[rowGroup], rowGroupIndices[rowGroup + 1] - 1); } template typename SparseMatrix::rows SparseMatrix::getRowGroup(index_type rowGroup) { + assert(rowGroup < this->getRowGroupCount()); return getRows(rowGroupIndices[rowGroup], rowGroupIndices[rowGroup + 1] - 1); } diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 7d7092377..555cd379c 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -799,6 +799,22 @@ namespace storm { */ rows getRow(index_type row); + /*! + * Returns an object representing the offset'th row in the rowgroup + * @param rowGroup the row group + * @param offset which row in the group + * @return An object representing the given row. + */ + const_rows getRow(index_type rowGroup, index_type offset) const; + + /*! + * Returns an object representing the offset'th row in the rowgroup + * @param rowGroup the row group + * @param offset which row in the group + * @return An object representing the given row. + */ + rows getRow(index_type rowGroup, index_type entryInGroup); + /*! * Returns an object representing the given row group. *