From 4f69c98c28f544b54550052bdf79b6a111d7a0aa Mon Sep 17 00:00:00 2001 From: Oliver Sander <sander@igpm.rwth-aachen.de> Date: Mon, 11 Apr 2011 08:18:29 +0000 Subject: [PATCH] add methods axpy and left-multiplication by a FieldMatrix [[Imported from SVN: r7135]] --- dune/gfe/tensor3.hh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/dune/gfe/tensor3.hh b/dune/gfe/tensor3.hh index 10144b79..fa18c10c 100644 --- a/dune/gfe/tensor3.hh +++ b/dune/gfe/tensor3.hh @@ -35,6 +35,13 @@ class Tensor3 return norm; } + Tensor3<T,N1,N2,N3>& axpy(const T& alpha, const Tensor3<T,N1,N2,N3>& other) + { + for (int i=0; i<N1; i++) + (*this)[i].axpy(alpha,other[i]); + return *this; + } + static Tensor3<T,N1,N2,N3> product(const Dune::FieldVector<T,N1>& a, const Dune::FieldVector<T,N2>& b, const Dune::FieldVector<T,N3>& c) { Tensor3<T,N1,N2,N3> result; @@ -87,6 +94,22 @@ class Tensor3 return result; } + template <int N4> + friend Tensor3<T,N1,N3,N4> operator*(const Dune::FieldMatrix<T,N1,N2>& a, const Tensor3<T,N2,N3,N4>& b) + { + Tensor3<T,N1,N3,N4> result; + + for (int i=0; i<N1; i++) + for (int j=0; j<N3; j++) + for (int k=0; k<N4; k++) { + result[i][j][k] = 0; + for (int l=0; l<N2; l++) + result[i][j][k] += a[i][l]*b[l][j][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