]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Fix compilation of a test. 16802/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2024 16:10:10 +0000 (10:10 -0600)
committerWolfgang Bangerth <bangerth@colostate.edu>
Thu, 28 Mar 2024 16:10:10 +0000 (10:10 -0600)
tests/symengine/symengine_tensor_operations_04.cc

index 747f1685928c807765dabd8dbacaf80d6b4b6465..f0bc1703d95df327e98d57232dd42a0884d2d3b1 100644 (file)
@@ -102,11 +102,20 @@ test_tensor()
   using Tensor_SD_number_t = Tensor<rank, dim, SD_number_t>;
   using Tensor_t           = Tensor<rank, dim, double>;
 
+  // Fill two tensors with ones and twos, respectively.
   Tensor_t t_a, t_b;
-  for (auto it = t_a.begin_raw(); it != t_a.end_raw(); ++it)
-    *it = 1.0;
-  for (auto it = t_b.begin_raw(); it != t_b.end_raw(); ++it)
-    *it = 2.0;
+  if constexpr (rank > 0)
+    {
+      for (unsigned int i = 0; i < Tensor_t::n_independent_components; ++i)
+        t_a[Tensor_t::unrolled_to_component_indices(i)] = 1.0;
+      for (unsigned int i = 0; i < Tensor_t::n_independent_components; ++i)
+        t_b[Tensor_t::unrolled_to_component_indices(i)] = 2.0;
+    }
+  else
+    {
+      t_a = 1.0;
+      t_b = 2.0;
+    }
 
   const Tensor_SD_number_t symb_t_a =
     SD::make_tensor_of_symbols<rank, dim>("a");

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.