aboutsummaryrefslogtreecommitdiff
path: root/aberth
diff options
context:
space:
mode:
Diffstat (limited to 'aberth')
-rw-r--r--aberth/aberth.cpp10
1 files 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 <array>
#include <string>
#include <complex>
+#include <random>
#include <utility>
#include <tuple>
#include <algorithm>
#include <thread>
#include <mutex>
-#include <cstdlib>
#include <cstdint>
#include <cassert>
#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<double>(-radius, radius)(randgenerator);
+ };
for (int i = 0; i < N; i++) {
approx[i] = Com(genCoord(), genCoord());
}
@@ -387,8 +391,6 @@ static vector<int32_t> invoke_kernel(
}
int main(int argc, char **argv) {
- srandomdev();
-
int W, H;
vector<int> counts;