From c2d55f1233bced1f2498e13ff7112d9624b97eb5 Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Sun, 10 Apr 2011 13:36:16 +0000 Subject: [PATCH] add contraction of a tensor with a matrix through the third index [[Imported from SVN: r7129]] --- dune/gfe/tensor3.hh | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/dune/gfe/tensor3.hh b/dune/gfe/tensor3.hh index ec900470..10144b79 100644 --- a/dune/gfe/tensor3.hh +++ b/dune/gfe/tensor3.hh @@ -70,7 +70,23 @@ class Tensor3 return result; } - + + template <int N4> + friend Tensor3<T,N1,N2,N4> operator*(const Tensor3<T,N1,N2,N3>& a, const Dune::FieldMatrix<T,N3,N4>& b) + { + Tensor3<T,N1,N2,N4> result; + + for (int i=0; i<N1; i++) + for (int j=0; j<N2; j++) + for (int k=0; k<N4; k++) { + result[i][j][k] = 0; + for (int l=0; l<N3; l++) + result[i][j][k] += a[i][j][l]*b[l][k]; + } + + return result; + } + friend Tensor3<T,N1,N2,N3> operator+(const Tensor3<T,N1,N2,N3>& a, const Tensor3<T,N1,N2,N3>& b) { Tensor3<T,N1,N2,N3> result; -- GitLab