From: kanschat Date: Wed, 1 Aug 2012 16:58:57 +0000 (+0000) Subject: add Frobenius inner product of two Tensor of rank 2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=859df98f0debba82c7f654aef20bc9598c50e00e;p=dealii-svn.git add Frobenius inner product of two Tensor of rank 2 git-svn-id: https://svn.dealii.org/trunk@25746 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/tensor.h b/deal.II/include/deal.II/base/tensor.h index d32dbe917a..c5a5bf1216 100644 --- a/deal.II/include/deal.II/base/tensor.h +++ b/deal.II/include/deal.II/base/tensor.h @@ -219,7 +219,7 @@ class Tensor /** * Return the square of the * Frobenius-norm of a tensor, - * i.e. the square root of the + * i.e. the * sum of squares of all entries. * * This function mainly exists @@ -691,6 +691,26 @@ operator * (const Tensor<1,dim,Number> &src1, } +/** + * Double contract two tensors of rank 2, thus computing the Frobenius + * inner product sumi,j src1[i][j]*src2[i][j]. + * + * @relates Tensor + * @author Guido Kanschat, 2000 + */ +template +inline +Number double_contract (const Tensor<2, dim, Number> &src1, + const Tensor<2, dim, Number> &src2) +{ + Number res = 0.; + for (unsigned int i=0; idest[i] = sum_j src1[i][j] src2[j].