From 114e2c5a62ee08a0c00ddfdc5f21d6cf732cd3b5 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@dune-project.org> Date: Wed, 4 Jul 2012 21:20:00 +0000 Subject: [PATCH] Implement helper class MatrixDimension for DiagonalMatrix and ScaledIdMatrix Patch by Uli Sack [[Imported from SVN: r1637]] --- dune/istl/matrixutils.hh | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/dune/istl/matrixutils.hh b/dune/istl/matrixutils.hh index f66d5fd31..8f2a37999 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 */ -- GitLab