From 3d23f92a8b706f54f8bc9d12009abafee53aeaf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org> Date: Sun, 3 Mar 2024 15:40:09 +0100 Subject: [PATCH] Export missing functionality in MatrixIndexSet The `MatrixIndexSet` class provides access to an incomplete subset of its internal data. While the number of rows is exported, the number of cols and the column indices per row have been missing so far. This was an oversight, since one can hardly use the class without this, unless one relies on the dedicated `exportIdx()` method for `BCRSMatrix`. With the missing data exported, one can now easily use `MatrixIndexSet` to build patterns for other sparse matrix classes. --- dune/istl/matrixindexset.hh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dune/istl/matrixindexset.hh b/dune/istl/matrixindexset.hh index ef31930dd..66b28ebdd 100644 --- a/dune/istl/matrixindexset.hh +++ b/dune/istl/matrixindexset.hh @@ -142,6 +142,22 @@ namespace Dune { /** \brief Return the number of rows */ size_type rows() const {return rows_;} + /** \brief Return the number of columns */ + size_type cols() const {return cols_;} + + /** + * \brief Return column indices of entries in given row + * + * This returns a range of all column indices + * that have been added for the given column. + * Since there are different internal implementations + * of this range, the result is stored in a std::variant<...> + * which has to be accessed using `std::visit`. + */ + const auto& columnIndices(size_type row) const { + return indices_[row]; + } + /** \brief Return the number of entries in a given row */ size_type rowsize(size_type row) const { return std::visit([&](const auto& rowIndices) { -- GitLab