From b5c9663a16980cef9cb7d9f1f46f87effb15f7d6 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Mon, 11 Jul 2016 21:37:37 +0200 Subject: [PATCH] Tests: Use C++11 random facilities --- dune/solvers/test/common.hh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dune/solvers/test/common.hh b/dune/solvers/test/common.hh index de788e3e..6dcaacdb 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' -- GitLab