From 725f9dec4e7927297938ee99faa5400d9af3be9f Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sat, 20 Apr 2019 10:38:59 +0200 Subject: Use C++ in normal aberth --- aberth/aberth.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/aberth/aberth.cpp b/aberth/aberth.cpp index 295e99c..02768e2 100644 --- a/aberth/aberth.cpp +++ b/aberth/aberth.cpp @@ -5,12 +5,12 @@ #include #include #include +#include #include #include #include #include #include -#include #include #include #include "../lodepng.h" @@ -109,6 +109,8 @@ static double maxRootNorm(const Poly &poly) { return 1 + value; } +static thread_local minstd_rand randgenerator = minstd_rand(random_device()()); + struct AberthState { const Poly &poly; Poly deriv; @@ -117,7 +119,9 @@ struct AberthState { double radius; void regenerate() { - auto genCoord = [this]() { return (double)random() / INT_MAX * 2 * radius - radius; }; + auto genCoord = [this]() { + return uniform_real_distribution(-radius, radius)(randgenerator); + }; for (int i = 0; i < N; i++) { approx[i] = Com(genCoord(), genCoord()); } @@ -387,8 +391,6 @@ static vector invoke_kernel( } int main(int argc, char **argv) { - srandomdev(); - int W, H; vector counts; -- cgit v1.2.3-70-g09d2