File tree 3 files changed +11
-39
lines changed
doc/api/next_api_changes/behavior
3 files changed +11
-39
lines changed Original file line number Diff line number Diff line change
1
+ ``TrapezoidMapTriFinder `` uses different random number generator
2
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3
+
4
+ The random number generator used to determine the order of insertion of
5
+ triangle edges in ``TrapezoidMapTriFinder `` has changed. This can result in a
6
+ different triangle index being returned for a point that lies exactly on an
7
+ edge between two triangles. This can also affect triangulation interpolation
8
+ and refinement algorithms that use ``TrapezoidMapTriFinder ``.
Original file line number Diff line number Diff line change 12
12
13
13
#include < algorithm>
14
14
#include < set>
15
+ #include < random>
15
16
16
17
17
18
TriEdge::TriEdge ()
@@ -1465,8 +1466,8 @@ TrapezoidMapTriFinder::initialize()
1465
1466
_tree->assert_valid (false );
1466
1467
1467
1468
// Randomly shuffle all edges other than first 2.
1468
- RandomNumberGenerator rng (1234 );
1469
- std::random_shuffle (_edges.begin ()+2 , _edges.end (), rng);
1469
+ std::mt19937 rng (1234 );
1470
+ std::shuffle (_edges.begin ()+2 , _edges.end (), rng);
1470
1471
1471
1472
// Add edges, one at a time, to tree.
1472
1473
size_t nedges = _edges.size ();
@@ -2056,16 +2057,3 @@ TrapezoidMapTriFinder::Trapezoid::set_upper_right(Trapezoid* upper_right_)
2056
2057
if (upper_right != 0 )
2057
2058
upper_right->upper_left = this ;
2058
2059
}
2059
-
2060
-
2061
-
2062
- RandomNumberGenerator::RandomNumberGenerator (unsigned long seed)
2063
- : _m(21870 ), _a(1291 ), _c(4621 ), _seed(seed % _m)
2064
- {}
2065
-
2066
- unsigned long
2067
- RandomNumberGenerator::operator ()(unsigned long max_value)
2068
- {
2069
- _seed = (_seed*_a + _c) % _m;
2070
- return (_seed*max_value) / _m;
2071
- }
Original file line number Diff line number Diff line change @@ -791,28 +791,4 @@ class TrapezoidMapTriFinder
791
791
Node* _tree; // Root node of the trapezoid map search tree. Owned.
792
792
};
793
793
794
-
795
-
796
- /* Linear congruential random number generator. Edges in the triangulation are
797
- * randomly shuffled before being added to the trapezoid map. Want the
798
- * shuffling to be identical across different operating systems and the same
799
- * regardless of previous random number use. Would prefer to use a STL or
800
- * Boost random number generator, but support is not consistent across
801
- * different operating systems so implementing own here.
802
- *
803
- * This is not particularly random, but is perfectly adequate for the use here.
804
- * Coefficients taken from Numerical Recipes in C. */
805
- class RandomNumberGenerator
806
- {
807
- public:
808
- RandomNumberGenerator (unsigned long seed);
809
-
810
- // Return random integer in the range 0 to max_value-1.
811
- unsigned long operator ()(unsigned long max_value);
812
-
813
- private:
814
- const unsigned long _m, _a, _c;
815
- unsigned long _seed;
816
- };
817
-
818
794
#endif
You can’t perform that action at this time.
0 commit comments