]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Augment documentation of class Tensor. 16803/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2024 16:12:30 +0000 (10:12 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2024 16:12:30 +0000 (10:12 -0600)
include/deal.II/base/tensor.h

index 07e53f92c8558b40d643207a063a25223ac61bb9..9d877de5afb33a32c7136909c91c9f75dbeb48dc 100644 (file)
@@ -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<rank,dim> t;
+   *   for (unsigned int i=0; i<Tensor<rank,dim>::n_independent_components; ++i)
+   *     t[Tensor<rank,dim>::unrolled_to_component_indices(i)] = 1.0;
+   * @endcode
    */
   static constexpr unsigned int n_independent_components =
     Tensor<rank_ - 1, dim>::n_independent_components * dim;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.