diff --git a/src/storm/storage/SparseMatrix.cpp b/src/storm/storage/SparseMatrix.cpp index e346e2fbb..2ca0c823c 100644 --- a/src/storm/storage/SparseMatrix.cpp +++ b/src/storm/storage/SparseMatrix.cpp @@ -2150,6 +2150,17 @@ namespace storm { return true; } + template + std::string SparseMatrix::getDimensionsAsString() const { + std::string result = std::to_string(getRowCount()) + "x" + std::to_string(getColumnCount()) + " matrix (" + std::to_string(getNonzeroEntryCount()) + " non-zeroes"; + if (!hasTrivialRowGrouping()) { + result += ", " + std::to_string(getRowGroupCount()) + " groups"; + } + result += ")"; + return result; + } + + template std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix) { // Print column numbers in header. diff --git a/src/storm/storage/SparseMatrix.h b/src/storm/storage/SparseMatrix.h index f742a7c49..d33eda907 100644 --- a/src/storm/storage/SparseMatrix.h +++ b/src/storm/storage/SparseMatrix.h @@ -963,6 +963,11 @@ namespace storm { template friend std::ostream& operator<<(std::ostream& out, SparseMatrix const& matrix); + /*! + * Returns a string describing the dimensions of the matrix. + */ + std::string getDimensionsAsString() const; + /*! * Prints the matrix in a dense format, as also used by e.g. Matlab. * Notice that the format does not support multiple rows in a rowgroup.