From: Jean-Paul Pelteret Date: Sun, 25 Sep 2016 20:24:54 +0000 (+0200) Subject: Add adjugate and cofactor functions to tensor class X-Git-Tag: v8.5.0-rc1~337^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=61b48fe5db8d6e94a3c90893ff47a55654e8a24b;p=dealii.git Add adjugate and cofactor functions to tensor class --- diff --git a/doc/news/changes.h b/doc/news/changes.h index 8a4f0e922d..633937745c 100644 --- a/doc/news/changes.h +++ b/doc/news/changes.h @@ -309,6 +309,12 @@ inconvenience this causes. (Denis Davydov, 2016/09/28) +
  • New: The Tensor class has two new functions implemented, namely those + that return its Tensor::adjoint() and Tensor::cofactor(). +
    + (Jean-Paul Pelteret, 2016/09/25) +
  • +
  • Improved: The doxygen documentation now contains nicely formatted boxes containing the text message of each exception. Several messages haven been clarified and improved. diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 78f857f80d..340e5bb201 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -1944,6 +1944,51 @@ transpose (const Tensor<2,dim,Number> &t) } +/** + * Return the adjugate of the given tensor of rank 2. + * The adjugate of a tensor $\left(\bullet\right)$ is defined as + * @f[ + * \textrm{adj}\left(\bullet\right) + * := \textrm{det}\left(\bullet\right) \; \left(\bullet\right)^{-1} \; . + * @f] + * + * @note This requires that the tensor is invertible. + * + * @relates Tensor + * @author Jean-Paul Pelteret, 2016 + */ +template +inline +Tensor<2,dim,Number> +adjugate (const Tensor<2,dim,Number> &t) +{ + return determinant(t)*invert(t); +} + + +/** + * Return the cofactor of the given tensor of rank 2. + * The cofactor of a tensor $\left(\bullet\right)$ is defined as + * @f[ + * \textrm{cof}\left(\bullet\right) + * := \textrm{det}\left(\bullet\right) \; \left(\bullet\right)^{-T} + * = \left[ \textrm{adj}\left(\bullet\right) \right]^{T} \; . + * @f] + * + * @note This requires that the tensor is invertible. + * + * @relates Tensor + * @author Jean-Paul Pelteret, 2016 + */ +template +inline +Tensor<2,dim,Number> +cofactor (const Tensor<2,dim,Number> &t) +{ + return transpose(adjugate(t)); +} + + /** * Return the $l_1$ norm of the given rank-2 tensor, where $||t||_1 = \max_j * \sum_i |t_{ij}|$ (maximum of the sums over columns).