From: David Wells Date: Sun, 12 Nov 2023 13:27:48 +0000 (-0500) Subject: SymmetricTensor: add a comment on indexing. X-Git-Tag: relicensing~304^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F16261%2Fhead;p=dealii.git SymmetricTensor: add a comment on indexing. --- diff --git a/include/deal.II/base/symmetric_tensor.h b/include/deal.II/base/symmetric_tensor.h index 9ce3e53895..7a31df5539 100644 --- a/include/deal.II/base/symmetric_tensor.h +++ b/include/deal.II/base/symmetric_tensor.h @@ -2057,7 +2057,11 @@ namespace internal std::min(indices[0], indices[1]), std::max(indices[0], indices[1])); - for (unsigned int d = 0, c = 0; d < dim; ++d) + // Here (d, e) are the row and column of the symmetric matrix and + // 'dim + c' is the index into the Tensor<1, dim> actually used + // for storage. + unsigned int c = 0; + for (unsigned int d = 0; d < dim; ++d) for (unsigned int e = d + 1; e < dim; ++e, ++c) if ((sorted_indices[0] == d) && (sorted_indices[1] == e)) return dim + c;