1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
From 3eb9987b02cc10b93e09219ddc86aa6be5f10177 Mon Sep 17 00:00:00 2001
From: tybeller <ty.c.beller@gmail.com>
Date: Fri, 30 Sep 2022 16:13:41 -0400
Subject: [PATCH] removed RandomNumberGenerator class, included <random>,
replaced random_shuffle with shuffle and used mersenne twister engine to
generate uniform random bit generator for the shuffle.
Upstream-Status: Backport [https://github.com/matplotlib/matplotlib/commit/601d92a8850]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/tri/_tri.cpp | 20 ++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)
diff --git a/src/tri/_tri.cpp b/src/tri/_tri.cpp
index b7a87783de..6e639eea44 100644
--- a/src/tri/_tri.cpp
+++ b/src/tri/_tri.cpp
@@ -12,6 +12,7 @@
#include <algorithm>
#include <set>
+#include <random>
TriEdge::TriEdge()
@@ -1465,8 +1466,8 @@ TrapezoidMapTriFinder::initialize()
_tree->assert_valid(false);
// Randomly shuffle all edges other than first 2.
- RandomNumberGenerator rng(1234);
- std::random_shuffle(_edges.begin()+2, _edges.end(), rng);
+ std::mt19937 rng(1234);
+ std::shuffle(_edges.begin()+2, _edges.end(), rng);
// Add edges, one at a time, to tree.
size_t nedges = _edges.size();
@@ -2055,17 +2056,4 @@ TrapezoidMapTriFinder::Trapezoid::set_upper_right(Trapezoid* upper_right_)
upper_right = upper_right_;
if (upper_right != 0)
upper_right->upper_left = this;
-}
-
-
-
-RandomNumberGenerator::RandomNumberGenerator(unsigned long seed)
- : _m(21870), _a(1291), _c(4621), _seed(seed % _m)
-{}
-
-unsigned long
-RandomNumberGenerator::operator()(unsigned long max_value)
-{
- _seed = (_seed*_a + _c) % _m;
- return (_seed*max_value) / _m;
-}
+}
\ No newline at end of file
--
2.39.0
|