From: wolf Date: Tue, 3 Sep 2002 15:24:02 +0000 (+0000) Subject: Implement the transpose of a tensor of rank 2. X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=506393086689532150d168d9c7bfbe15e7b83904;p=dealii-svn.git Implement the transpose of a tensor of rank 2. git-svn-id: https://svn.dealii.org/trunk@6345 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/base/include/base/tensor.h b/deal.II/base/include/base/tensor.h index 771a26115c..52ea6f6ffe 100644 --- a/deal.II/base/include/base/tensor.h +++ b/deal.II/base/include/base/tensor.h @@ -1012,6 +1012,85 @@ invert (const Tensor<2,dim> &t) +/** + * Return the transpose of the given tensor. Since the compiler can + * perform the return value optimization, and since the size of the + * return object is known, it is acceptable to return the result by + * value, rather than by reference as a parameter. Note that there are + * specializations of this function for @p{dim==1,2,3}. + * + * @author Wolfgang Bangerth, 2002 + */ +template +inline +Tensor<2,dim> +transpose (const Tensor<2,dim> &t) +{ + Tensor<2,dim> tt = t; + for (unsigned int i=0; i +transpose (const Tensor<2,1> &t) +{ + return t; +}; + + + + +/** + * Return the transpose of the given tensor. This is the + * specialization of the general template for @p{dim==2}. + * + * @author Wolfgang Bangerth, 2002 + */ +inline +Tensor<2,2> +transpose (const Tensor<2,2> &t) +{ + const double x[2][2] = {{t[0][0], t[1][0]}, {t[0][1], t[1][1]}}; + return Tensor<2,2>(x); +}; + + + + +/** + * Return the transpose of the given tensor. This is the + * specialization of the general template for @p{dim==3}. + * + * @author Wolfgang Bangerth, 2002 + */ +inline +Tensor<2,3> +transpose (const Tensor<2,3> &t) +{ + const double x[3][3] = {{t[0][0], t[1][0], t[2][0]}, + {t[0][1], t[1][1], t[2][1]}, + {t[0][2], t[1][2], t[2][2]}}; + return Tensor<2,3>(x); +}; + + + + /** * Multiplication of a tensor of general rank with a scalar double * from the right. diff --git a/deal.II/doc/news/2002/c-3-4.html b/deal.II/doc/news/2002/c-3-4.html index c5a1c4f870..5eae17f432 100644 --- a/deal.II/doc/news/2002/c-3-4.html +++ b/deal.II/doc/news/2002/c-3-4.html @@ -95,6 +95,13 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK

base

    +
  1. + New: There are now functions returning the transpose of Tensor objects of rank 2. +
    + (WB 2002/08/31) +

    +
  2. New: Row accessors for the vector2d class now have a member function -

  3. Fix: Bug in

    Fixed: Bug in Triangulation<3>::load_user_flags(vector<bool> &) is now fixed.
    @@ -226,7 +233,7 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK (RH 2002/06/14)

    -
  4. Change:

    Changed: Triangulation<1>::n_quads now returns 0, instead of throwing an assertion, as before. The same holds for similar functions like