Skip to content
Snippets Groups Projects
Commit b5c9663a authored by Elias Pipping's avatar Elias Pipping
Browse files

Tests: Use C++11 random facilities

parent 76ec89a7
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#ifndef DUNE_SOLVERS_TESTS_COMMON_HH #ifndef DUNE_SOLVERS_TESTS_COMMON_HH
#define DUNE_SOLVERS_TESTS_COMMON_HH #define DUNE_SOLVERS_TESTS_COMMON_HH
#include <random>
#include <dune/common/fvector.hh> #include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh> #include <dune/common/fmatrix.hh>
...@@ -393,6 +394,9 @@ public: ...@@ -393,6 +394,9 @@ public:
} }
void randomize() { void randomize() {
std::default_random_engine generator;
std::uniform_real_distribution<double> distribution(-1, 1);
// Set up a random 'solution' // Set up a random 'solution'
u = 0; u = 0;
for (size_t i = 0; i < u.size(); ++i) for (size_t i = 0; i < u.size(); ++i)
...@@ -400,7 +404,7 @@ public: ...@@ -400,7 +404,7 @@ public:
// Make the matrix positive-definitive // Make the matrix positive-definitive
if (not trivialDirichletOnly) if (not trivialDirichletOnly)
A[i][i][j][j] += 0.5*std::abs(A[0][0][0][0]); 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' // Construct right hand side corresponding to the 'solution'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment