From 31ef576c4ff815a35402de2f7e7159f09f6076ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carsten=20Gr=C3=A4ser?= <graeser@dune-project.org>
Date: Mon, 9 Nov 2009 21:54:54 +0000
Subject: [PATCH] =?UTF-8?q?*Fix=20bug=20in=20rightmultiply()=20*Add=20cons?=
 =?UTF-8?q?t=20to=20*multiplyany()=20*Implement=20*multiplyany()=20for=20F?=
 =?UTF-8?q?ieldMatrix<k,1,1>=20Thanks=20to=20Atgeirr=20Fl=C3=B8=20Rasmusse?=
 =?UTF-8?q?n!?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

[[Imported from SVN: r5704]]
---
 dune/common/fmatrix.hh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/dune/common/fmatrix.hh b/dune/common/fmatrix.hh
index 17882e82a..82daacdca 100644
--- a/dune/common/fmatrix.hh
+++ b/dune/common/fmatrix.hh
@@ -513,7 +513,7 @@ namespace Dune
 
     //! Multiplies M from the left to this matrix, this matrix is not modified
     template<int l>
-    FieldMatrix<K,l,cols> leftmultiplyany (const FieldMatrix<K,l,rows>& M)
+    FieldMatrix<K,l,cols> leftmultiplyany (const FieldMatrix<K,l,rows>& M) const
     {
       FieldMatrix<K,l,cols> C;
 
@@ -535,7 +535,7 @@ namespace Dune
       for (size_type i=0; i<rows; i++)
         for (size_type j=0; j<cols; j++) {
           (*this)[i][j] = 0;
-          for (size_type k=0; k<rows; k++)
+          for (size_type k=0; k<cols; k++)
             (*this)[i][j] += C[i][k]*M[k][j];
         }
       return *this;
@@ -543,7 +543,7 @@ namespace Dune
 
     //! Multiplies M from the right to this matrix, this matrix is not modified
     template<int l>
-    FieldMatrix<K,rows,l> rightmultiplyany (const FieldMatrix<K,cols,l>& M)
+    FieldMatrix<K,rows,l> rightmultiplyany (const FieldMatrix<K,cols,l>& M) const
     {
       FieldMatrix<K,rows,l> C;
 
@@ -1219,6 +1219,16 @@ namespace Dune
       return *this;
     }
 
+    //! Multiplies M from the left to this matrix, this matrix is not modified
+    template<int l>
+    FieldMatrix<K,l,1> leftmultiplyany (const FieldMatrix<K,l,1>& M) const
+    {
+      FieldMatrix<K,l,1> C;
+      for (size_type j=0; j<l; j++)
+        C[j][0] = M[j][0]*a[0];
+      return C;
+    }
+
     //! left multiplication
     FieldMatrix& rightmultiply (const FieldMatrix& M)
     {
@@ -1226,6 +1236,16 @@ namespace Dune
       return *this;
     }
 
+    //! Multiplies M from the right to this matrix, this matrix is not modified
+    template<int l>
+    FieldMatrix<K,1,l> rightmultiplyany (const FieldMatrix<K,1,l>& M) const
+    {
+      FieldMatrix<K,1,l> C;
+
+      for (size_type j=0; j<l; j++)
+        C[0][j] = M[0][j]*a[0];
+      return C;
+    }
 
     //===== sizes
 
-- 
GitLab