From 8fcca97dcd21b66bc9382a0b724bd6d9bf7ce57a Mon Sep 17 00:00:00 2001 From: wolf Date: Thu, 12 Apr 2001 10:21:01 +0000 Subject: [PATCH] Trace of a tensor. git-svn-id: https://svn.dealii.org/trunk@4451 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/base/include/base/tensor.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h index 825256a229..e4ee3b97d4 100644 --- a/deal.II/base/include/base/tensor.h +++ b/deal.II/base/include/base/tensor.h @@ -921,6 +921,23 @@ double determinant (const Tensor<2,3> &t) +/** + * Compute and return the trace of a tensor of rank 2, i.e. the sum of + * its diagonal entries. + * + * @author Wolfgang Bangerth, 2001 + */ +template +double trace (const Tensor<2,dim> &d) +{ + double t=0; + for (unsigned int i=0; i