From 859df98f0debba82c7f654aef20bc9598c50e00e Mon Sep 17 00:00:00 2001 From: kanschat Date: Wed, 1 Aug 2012 16:58:57 +0000 Subject: [PATCH] add Frobenius inner product of two Tensor of rank 2 git-svn-id: https://svn.dealii.org/trunk@25746 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/include/deal.II/base/tensor.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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]. -- 2.39.5