From: Wolfgang Bangerth Date: Thu, 12 Apr 2001 10:21:01 +0000 (+0000) Subject: Trace of a tensor. X-Git-Tag: v8.0.0~19335 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=042741e17872319f519823d779dc6110df6873ac;p=dealii.git Trace of a tensor. git-svn-id: https://svn.dealii.org/trunk@4451 0785d39b-7218-0410-832d-ea1e28bc413d --- 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