From fcba3a54abfcfba801577d6bd2a100509768be12 Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Mon, 15 Jan 2001 09:57:34 +0000 Subject: [PATCH] scalar product of tensors git-svn-id: https://svn.dealii.org/trunk@3656 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/tensor.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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