From 56e9fc577355243d590d80581aba91357fbb022f Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Thu, 28 Mar 2024 10:12:30 -0600 Subject: [PATCH] Augment documentation of class Tensor. --- include/deal.II/base/tensor.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/deal.II/base/tensor.h b/include/deal.II/base/tensor.h index 07e53f92c8..9d877de5af 100644 --- a/include/deal.II/base/tensor.h +++ b/include/deal.II/base/tensor.h @@ -541,7 +541,17 @@ public: /** * Number of independent components of a tensor of current rank. This is dim - * times the number of independent components of each sub-tensor. + * times the number of independent components of each sub-tensor, which + * equates to `dim^rank`. + * + * This number can be used to loop over all of the entries of a tensor, + * using the unrolled_to_component_indices() function: + * @code + * // Fill a tensor of arbitrary rank with ones: + * Tensor t; + * for (unsigned int i=0; i::n_independent_components; ++i) + * t[Tensor::unrolled_to_component_indices(i)] = 1.0; + * @endcode */ static constexpr unsigned int n_independent_components = Tensor::n_independent_components * dim; -- 2.39.5