From 148a84f4a7c85bcb6cc883b3f1d557d5a6ab9857 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Wed, 25 Sep 2024 15:21:06 +0200 Subject: [PATCH] Use C++ random (#632) --- .clang-tidy | 1 + tests/splines/batched_2d_spline_builder.cpp | 2 +- tests/splines/polynomial_evaluator.hpp | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 923503c02..8f292d7b1 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -10,6 +10,7 @@ bugprone-*, -bugprone-integer-division, -bugprone-narrowing-conversions, -bugprone-unchecked-optional-access, +cert-msc50-cpp, google-readability-avoid-underscore-in-googletest-name, hicpp-avoid-c-arrays, misc-*, diff --git a/tests/splines/batched_2d_spline_builder.cpp b/tests/splines/batched_2d_spline_builder.cpp index 8d8a2986d..a14ae3dfd 100644 --- a/tests/splines/batched_2d_spline_builder.cpp +++ b/tests/splines/batched_2d_spline_builder.cpp @@ -666,7 +666,7 @@ static void Batched2dSplineTest() dx(ncells), s_degree, s_degree), - 1e-12 * max_norm_diff12)); + 1e-11 * max_norm_diff12)); } #if defined(BC_PERIODIC) && defined(BSPLINES_TYPE_UNIFORM) diff --git a/tests/splines/polynomial_evaluator.hpp b/tests/splines/polynomial_evaluator.hpp index 27ada66a5..145ef127e 100644 --- a/tests/splines/polynomial_evaluator.hpp +++ b/tests/splines/polynomial_evaluator.hpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include @@ -29,8 +29,11 @@ struct PolynomialEvaluator template Evaluator(Domain domain) : m_xN(std::max(std::abs(rmin(domain)), std::abs(rmax(domain)))) { + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_real_distribution dis(0., 1.); for (int i(0); i < Degree + 1; ++i) { - m_coeffs[i] = double(rand() % 100) / 100.0; + m_coeffs[i] = dis(gen); } }