From: Guido Kanschat Date: Mon, 15 Jan 2001 09:57:34 +0000 (+0000) Subject: scalar product of tensors X-Git-Tag: v8.0.0~19823 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fcba3a54abfcfba801577d6bd2a100509768be12;p=dealii.git scalar product of tensors git-svn-id: https://svn.dealii.org/trunk@3656 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h index 750bfc1b0a..92486dabe6 100644 --- a/deal.II/base/include/base/tensor.h +++ b/deal.II/base/include/base/tensor.h @@ -397,6 +397,25 @@ DeclException1 (ExcInvalidTensorIndex, << "Invalid tensor index " << arg1); +/** + * Contract a tensor of rank 1 with a tensor of rank 1. The result is + * @p{sum_j src1[j] src2[j]}. + * + * @author Guido Kanschat, 2000 + */ +template +inline +double contract (const Tensor<1,dim> &src1, + const Tensor<1,dim> &src2) +{ + double res = 0.; + for (unsigned int i=0; i