From: Martin Kronbichler Date: Tue, 30 Jul 2019 08:24:56 +0000 (+0200) Subject: Simplify symmetrize(Tensor<2,dim>) X-Git-Tag: v9.2.0-rc1~1330^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=26989579d51a76cb451e6cb84fc2fd24c6d79428;p=dealii.git Simplify symmetrize(Tensor<2,dim>) --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 127a145a5b..4e61bcc597 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -3469,15 +3469,14 @@ template DEAL_II_CONSTEXPR inline DEAL_II_ALWAYS_INLINE SymmetricTensor<2, dim, Number> symmetrize(const Tensor<2, dim, Number> &t) { - Number array[(dim * dim + dim) / 2]; + SymmetricTensor<2, dim, Number> result; for (unsigned int d = 0; d < dim; ++d) - array[d] = t[d][d]; - Number half = {}; - half = 0.5; - for (unsigned int d = 0, c = dim; d < dim; ++d) - for (unsigned int e = d + 1; e < dim; ++e, ++c) - array[c] = (t[d][e] + t[e][d]) * half; - return SymmetricTensor<2, dim, Number>(array); + result[d][d] = t[d][d]; + Number half = 0.5; + for (unsigned int d = 0; d < dim; ++d) + for (unsigned int e = d + 1; e < dim; ++e) + result[d][e] = (t[d][e] + t[e][d]) * half; + return result; }