diff --git a/src/storage/SparseMatrix.h b/src/storage/SparseMatrix.h index 856261c4f..8a98c1b57 100644 --- a/src/storage/SparseMatrix.h +++ b/src/storage/SparseMatrix.h @@ -772,6 +772,23 @@ namespace storm { * @return An iterator that points past the end of the last row of the matrix. */ iterator end(); + + /*! + * Returns a copy of the matrix with the chosen internal data type + */ + template + SparseMatrix toValueType() const { + std::vector> new_columnsAndValues; + std::vector new_rowIndications(rowIndications); + std::vector new_rowGroupIndices(rowGroupIndices); + + new_columnsAndValues.resize(columnsAndValues.size()); + for (size_t i = 0, size = columnsAndValues.size(); i < size; ++i) { + new_columnsAndValues.at(i) = MatrixEntry(columnsAndValues.at(i).getColumn(), static_cast(columnsAndValues.at(i).getValue())); + } + + return SparseMatrix(columnCount, std::move(new_rowIndications), std::move(new_columnsAndValues), std::move(new_rowGroupIndices)); + } private: /*!