]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add adjugate and cofactor functions to tensor class
authorJean-Paul Pelteret <jppelteret@gmail.com>
Sun, 25 Sep 2016 20:24:54 +0000 (22:24 +0200)
committerJean-Paul Pelteret <jppelteret@gmail.com>
Fri, 9 Dec 2016 15:00:48 +0000 (16:00 +0100)
doc/news/changes.h
include/deal.II/base/tensor.h

index 8a4f0e922df7b16a3f37058382d97436dd148a1e..633937745c596f296460b20937ff0556d20b4146 100644 (file)
@@ -309,6 +309,12 @@ inconvenience this causes.
  (Denis Davydov, 2016/09/28)
  </li>
 
+ <li> New: The Tensor class has two new functions implemented, namely those
+ that return its Tensor::adjoint() and Tensor::cofactor().
+ <br>
+ (Jean-Paul Pelteret, 2016/09/25)
+ </li>
+
  <li> Improved: The doxygen documentation now contains nicely formatted
  boxes containing the text message of each exception. Several messages
  haven been clarified and improved.
index 78f857f80dcc23ecd901823471ce4cf658107c71..340e5bb2011e99de3b542aeb2f4b86da9ba794db 100644 (file)
@@ -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 <int dim, typename Number>
+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 <int dim, typename Number>
+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).

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.