From afc294f86619f159e07a7bce21fb85c6eff4d979 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Mon, 14 Sep 2015 22:03:43 -0500 Subject: [PATCH] tensor.h: Remove specializations for transpose With modern compilers the generic implementation is efficient enough - it will be optimized to those specializations... --- include/deal.II/base/tensor.h | 66 ++--------------------------------- 1 file changed, 3 insertions(+), 63 deletions(-) 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 -- 2.39.5