From d9f896dd10c39b3e4cfe930661c181027067ae69 Mon Sep 17 00:00:00 2001
From: Lisa Julia Nebel <lisa_julia.nebel@tu-dresden.de>
Date: Thu, 10 Jun 2021 11:12:59 +0200
Subject: [PATCH] Add multiplication of a ScaledIdentityMatrix with another
 FieldMatrix to the collection in linearalgebra.hh

---
 dune/gfe/linearalgebra.hh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/dune/gfe/linearalgebra.hh b/dune/gfe/linearalgebra.hh
index f23d3ea9..1a08a863 100644
--- a/dune/gfe/linearalgebra.hh
+++ b/dune/gfe/linearalgebra.hh
@@ -3,6 +3,7 @@
 
 #include <dune/common/fmatrix.hh>
 #include <dune/common/version.hh>
+#include <dune/istl/scaledidmatrix.hh>
 
 
 ///////////////////////////////////////////////////////////////////////////////////////////
@@ -13,6 +14,20 @@ namespace Dune {
 
   namespace GFE {
 
+  /** \brief Multiplication of a ScalecIdentityMatrix with another FieldMatrix */
+  template <class T, int N, int otherCols>
+  Dune::FieldMatrix<T,N,otherCols> operator* ( const Dune::ScaledIdentityMatrix<T, N>& diagonalMatrix,
+                        const Dune::FieldMatrix<T, N, otherCols>& matrix)
+  {
+      Dune::FieldMatrix<T,N,otherCols> result(0);
+
+      for (size_t i = 0; i < N; ++i)
+        for (size_t j = 0; j < otherCols; ++j)
+          result[i][j] = diagonalMatrix[i][i]*matrix[i][j];
+
+      return result;
+  }
+
   /** \brief Return the trace of a matrix */
   template <class T, int n>
   static T trace(const FieldMatrix<T,n,n>& A)
-- 
GitLab