From: Jean-Paul Pelteret Date: Sat, 12 Aug 2017 07:05:43 +0000 (-0600) Subject: Explicitly initialise tensor contraction results to zero. X-Git-Tag: v9.0.0-rc1~1244^2~4 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=acfa8a551a46f780ab69ffa2e67cbada71a08e35;p=dealii.git Explicitly initialise tensor contraction results to zero. --- diff --git a/include/deal.II/base/tensor_accessors.h b/include/deal.II/base/tensor_accessors.h index 52c7ca7bf1..2ca2674e47 100644 --- a/include/deal.II/base/tensor_accessors.h +++ b/include/deal.II/base/tensor_accessors.h @@ -665,7 +665,9 @@ namespace TensorAccessors inline DEAL_II_ALWAYS_INLINE static T1 contract2(const T2 &left, const T3 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract2::template contract2(left[i], right[i]); return result; @@ -710,7 +712,9 @@ namespace TensorAccessors static inline T1 contract3(const T2 &left, const T3 &middle, const T4 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract3::template contract3(left[i], middle[i], right); return result; @@ -736,7 +740,9 @@ namespace TensorAccessors static inline T1 contract3(const T2 &left, const T3 &middle, const T4 &right) { - T1 result = T1(); + // Some auto-differentiable numbers need explicit + // zero initialization. + T1 result = dealii::internal::NumberType::value(0.0); for (unsigned int i = 0; i < dim; ++i) result += Contract3<0, rank_2 - 1, dim>::template contract3(left, middle[i], right[i]); return result;