From: Matthias Maier Date: Tue, 15 Sep 2015 03:03:43 +0000 (-0500) Subject: tensor.h: Remove specializations for transpose X-Git-Tag: v8.4.0-rc2~413^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=afc294f86619f159e07a7bce21fb85c6eff4d979;p=dealii.git tensor.h: Remove specializations for transpose With modern compilers the generic implementation is efficient enough - it will be optimized to those specializations... --- diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 33f52683c7..eb7bc279d1 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -2286,11 +2286,7 @@ invert (const Tensor<2,dim,Number> &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 dim==1,2,3. + * Return the transpose of the given tensor. * * @relates Tensor * @author Wolfgang Bangerth, 2002 @@ -2300,7 +2296,7 @@ inline Tensor<2,dim,Number> transpose (const Tensor<2,dim,Number> &t) { - Number tt[dim][dim]; + Tensor<2, dim, Number> tt; for (unsigned int i=0; i &t) tt[j][i] = t[i][j]; }; } - return Tensor<2,dim,Number>(tt); -} - -#ifndef DOXYGEN - -/** - * Return the transpose of the given tensor. This is the specialization of the - * general template for dim==1. - * - * @relates Tensor - * @author Wolfgang Bangerth, 2002 - */ -template -inline -Tensor<2,1,Number> -transpose (const Tensor<2,1,Number> &t) -{ - return t; -} - - -/** - * Return the transpose of the given tensor. This is the specialization of the - * general template for dim==2. - * - * @relates Tensor - * @author Wolfgang Bangerth, 2002 - */ -template -inline -Tensor<2,2,Number> -transpose (const Tensor<2,2,Number> &t) -{ - const Number x[2][2] = {{t[0][0], t[1][0]}, {t[0][1], t[1][1]}}; - return Tensor<2,2,Number>(x); -} - - -/** - * Return the transpose of the given tensor. This is the specialization of the - * general template for dim==3. - * - * @relates Tensor - * @author Wolfgang Bangerth, 2002 - */ -template -inline -Tensor<2,3,Number> -transpose (const Tensor<2,3,Number> &t) -{ - const Number 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,Number>(x); + return tt; } -#endif // DOXYGEN - /** * Return the $l_1$ norm of the given rank-2 tensor, where $||t||_1 = \max_j