]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use std::iota, document problems 8332/head
authorDaniel Arndt <arndtd@ornl.gov>
Thu, 27 Jun 2019 20:20:10 +0000 (16:20 -0400)
committerDaniel Arndt <arndtd@ornl.gov>
Thu, 27 Jun 2019 20:40:14 +0000 (16:40 -0400)
source/base/function_parser.cc
source/base/utilities.cc
source/dofs/dof_renumbering.cc
source/grid/grid_tools.cc

index e128460f7956754333c774b1ff7621eb032a973e..1c40150bfa37d4070cd8667ac546ff65f6ddfc28 100644 (file)
@@ -248,6 +248,8 @@ namespace internal
 
     // for each seed an unique random number generator is created,
     // which is initialized with the seed itself
+    // we could use std::mt19937 but doing so results in compiler-dependent
+    // output.
     static std::map<double, boost::random::mt19937> rng_map;
 
     if (rng_map.find(seed) == rng_map.end())
index 84d268deb5ff965e313fe16203c7f3ecde01d4cd..7b77133809c007ffd20f0db9ca37ae872397362d 100644 (file)
@@ -764,7 +764,9 @@ namespace Utilities
     // in a thread context. one could use rand_r, but this does not
     // produce reproducible results between threads either (though at
     // least it is reentrant). these two approaches being
-    // non-workable, use a thread-local random number generator here
+    // non-workable, use a thread-local random number generator here.
+    // we could use std::mt19937 but doing so results in compiler-dependent
+    // output.
     static Threads::ThreadLocalStorage<boost::mt19937> random_number_generator;
     return boost::normal_distribution<>(a,
                                         sigma)(random_number_generator.get());
index 8487699a8d5bebf7497b5acc19545587b46a5580..9e22ce347fb4cb9bd5a2615d0e0d0074705e20c3 100644 (file)
@@ -2134,11 +2134,14 @@ namespace DoFRenumbering
     Assert(new_indices.size() == n_dofs,
            ExcDimensionMismatch(new_indices.size(), n_dofs));
 
-    for (unsigned int i = 0; i < n_dofs; ++i)
-      new_indices[i] = i;
+    std::iota(new_indices.begin(),
+              new_indices.end(),
+              types::global_dof_index(0));
 
     // shuffle the elements; the following is essentially std::shuffle (which
     // is new in C++11) but with a boost URNG
+    // we could use std::mt19937 here but doing so results in compiler-dependent
+    // output
     ::boost::mt19937 random_number_generator;
     for (unsigned int i = 1; i < n_dofs; ++i)
       {
@@ -2165,11 +2168,14 @@ namespace DoFRenumbering
     Assert(new_indices.size() == n_dofs,
            ExcDimensionMismatch(new_indices.size(), n_dofs));
 
-    for (unsigned int i = 0; i < n_dofs; ++i)
-      new_indices[i] = i;
+    std::iota(new_indices.begin(),
+              new_indices.end(),
+              types::global_dof_index(0));
 
     // shuffle the elements; the following is essentially std::shuffle (which
     // is new in C++11) but with a boost URNG
+    // we could use std::mt19937 here but doing so results in
+    // compiler-dependent output
     ::boost::mt19937 random_number_generator;
     for (unsigned int i = 1; i < n_dofs; ++i)
       {
index 3f28240a684d210ab4164f63dbd45a7e9cd7d75e..d0890f014d235072e6cdbd1304aae2475ab066c9 100644 (file)
@@ -1172,6 +1172,8 @@ namespace GridTools
     // if you call the function twice on the same mesh, then you will
     // get the same mesh. this would not be the case if you used
     // the rand() function, which carries around some internal state
+    // we could use std::mt19937 but doing so results in compiler-dependent
+    // output.
     boost::random::mt19937                     rng;
     boost::random::uniform_real_distribution<> uniform_distribution(-1, 1);
 

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.