diff --git a/dune/istl/matrixutils.hh b/dune/istl/matrixutils.hh index f66d5fd314965c1a57305c22802129f97216ecef..8f2a37999996db4ef33fe0f3f5d226669b7e8736 100644 --- a/dune/istl/matrixutils.hh +++ b/dune/istl/matrixutils.hh @@ -9,6 +9,8 @@ #include <dune/common/typetraits.hh> #include <dune/common/static_assert.hh> #include <dune/common/fmatrix.hh> +#include <dune/istl/diagonalmatrix.hh> +#include <dune/istl/scaledidmatrix.hh> #include <dune/istl/bcrsmatrix.hh> #include "istlexception.hh" @@ -388,6 +390,60 @@ namespace Dune } }; + template<typename K, int n> + struct MatrixDimension<DiagonalMatrix<K,n> > + { + typedef DiagonalMatrix<K,n> Matrix; + typedef typename Matrix::size_type size_type; + + static size_type rowdim(const Matrix& A, size_type r) + { + return 1; + } + + static size_type coldim(const Matrix& A, size_type r) + { + return 1; + } + + static size_type rowdim(const Matrix& A) + { + return n; + } + + static size_type coldim(const Matrix& A) + { + return n; + } + }; + + template<typename K, int n> + struct MatrixDimension<ScaledIdentityMatrix<K,n> > + { + typedef ScaledIdentityMatrix<K,n> Matrix; + typedef typename Matrix::size_type size_type; + + static size_type rowdim(const Matrix& A, size_type r) + { + return 1; + } + + static size_type coldim(const Matrix& A, size_type r) + { + return 1; + } + + static size_type rowdim(const Matrix& A) + { + return n; + } + + static size_type coldim(const Matrix& A) + { + return n; + } + }; + /** * @brief Test whether a type is an ISTL Matrix */