diff --git a/dune/solvers/test/common.hh b/dune/solvers/test/common.hh index de788e3e3a7d14403b50be3dc39151103acc32ba..6dcaacdb5950b95059df9fdc725ecbc5a37845c2 100644 --- a/dune/solvers/test/common.hh +++ b/dune/solvers/test/common.hh @@ -3,6 +3,7 @@ #ifndef DUNE_SOLVERS_TESTS_COMMON_HH #define DUNE_SOLVERS_TESTS_COMMON_HH +#include <random> #include <dune/common/fvector.hh> #include <dune/common/fmatrix.hh> @@ -393,6 +394,9 @@ public: } void randomize() { + std::default_random_engine generator; + std::uniform_real_distribution<double> distribution(-1, 1); + // Set up a random 'solution' u = 0; for (size_t i = 0; i < u.size(); ++i) @@ -400,7 +404,7 @@ public: // Make the matrix positive-definitive if (not trivialDirichletOnly) A[i][i][j][j] += 0.5*std::abs(A[0][0][0][0]); - u_ex[i][j] = (1.0 * rand()) / RAND_MAX; + u_ex[i][j] = distribution(generator); } // Construct right hand side corresponding to the 'solution'