From ed194eb2a76874b07856dd32c46b013b887941aa Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 12 Nov 2023 08:27:48 -0500 Subject: [PATCH] SymmetricTensor: add a comment on indexing. --- include/deal.II/base/symmetric_tensor.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; -- 2.39.5