From 601d92a885031e97caa84ce014437cae7ce213fa Mon Sep 17 00:00:00 2001 From: tybeller Date: Fri, 30 Sep 2022 16:13:41 -0400 Subject: [PATCH 01/10] removed RandomNumberGenerator class, included , replaced random_shuffle with shuffle and used mersenne twister engine to generate uniform random bit generator for the shuffle. --- 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 b7a87783de29..6e639eea44d9 100644 --- a/src/tri/_tri.cpp +++ b/src/tri/_tri.cpp @@ -12,6 +12,7 @@ #include #include +#include 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 From 1ae361008c55f05c1786e127fffdf06ab99c58a3 Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Sun, 2 Oct 2022 18:25:30 -0400 Subject: [PATCH 02/10] Create 24062-tb.rst Added API notes for changed output from TrapezoidMapTriFinder, triangulation interpolation, and refinement --- doc/api/next_api_changes/behavior/24062-tb.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/api/next_api_changes/behavior/24062-tb.rst diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst new file mode 100644 index 000000000000..d24a92326829 --- /dev/null +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -0,0 +1,3 @@ +Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +With std::random_shuffle removed from C++17, TrapezouidMapTriFinder, triangular interpolation, and refinement now use std::shuffle with a new random generator leading to a different output. From c8e05317190e1b8adbae8fbeb38ffbcbd9f43e74 Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Tue, 4 Oct 2022 13:09:15 -0400 Subject: [PATCH 03/10] Update doc/api/next_api_changes/behavior/24062-tb.rst Fix api change Co-authored-by: Ian Thomas --- doc/api/next_api_changes/behavior/24062-tb.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst index d24a92326829..bd45ec6997f5 100644 --- a/doc/api/next_api_changes/behavior/24062-tb.rst +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -1,3 +1,3 @@ Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -With std::random_shuffle removed from C++17, TrapezouidMapTriFinder, triangular interpolation, and refinement now use std::shuffle with a new random generator leading to a different output. +With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may give different results. From bd3dc8ae4093055e15269613919ec61aca559fed Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Wed, 5 Oct 2022 03:34:47 -0400 Subject: [PATCH 04/10] Update doc/api/next_api_changes/behavior/24062-tb.rst Co-authored-by: Oscar Gustafsson --- doc/api/next_api_changes/behavior/24062-tb.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst index bd45ec6997f5..96a470424485 100644 --- a/doc/api/next_api_changes/behavior/24062-tb.rst +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -1,3 +1,3 @@ Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may give different results. From 4648dda9c9c24e14468b3f85eab2920cc56cd8bd Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:12:14 -0400 Subject: [PATCH 05/10] Update 24062-tb.rst --- doc/api/next_api_changes/behavior/24062-tb.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst index 96a470424485..5a7d03f7c86c 100644 --- a/doc/api/next_api_changes/behavior/24062-tb.rst +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -1,3 +1,3 @@ Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may give different results. +With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may yield altered outputs due to the differently randomized edges. From d77b1910e2bcbb242d237f9554829b98a857f63a Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Wed, 5 Oct 2022 20:38:25 -0400 Subject: [PATCH 06/10] Update 24062-tb.rst clarified that the conditions of the change in output --- doc/api/next_api_changes/behavior/24062-tb.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst index 5a7d03f7c86c..00f3c97d7ebd 100644 --- a/doc/api/next_api_changes/behavior/24062-tb.rst +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -1,3 +1,3 @@ Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which may yield altered outputs due to the differently randomized edges. +With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which will serve the same purpose but may yield altered outputs compared to previous versions due to the differently randomized edges. From e096d5ea5640d63736993a5b0962e3540ea71511 Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Wed, 12 Oct 2022 19:09:48 -0400 Subject: [PATCH 07/10] Update 24062-tb.rst Updated with ianthomas23's API documentations --- doc/api/next_api_changes/behavior/24062-tb.rst | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/doc/api/next_api_changes/behavior/24062-tb.rst b/doc/api/next_api_changes/behavior/24062-tb.rst index 00f3c97d7ebd..7e5beaecba53 100644 --- a/doc/api/next_api_changes/behavior/24062-tb.rst +++ b/doc/api/next_api_changes/behavior/24062-tb.rst @@ -1,3 +1,8 @@ -Change in TrapezoidMapTriFinder, triangulation interpolation, and refinement output due to change in shuffle. -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -With std::random_shuffle removed from C++17, TrapezoidMapTriFinder, triangular grid interpolation and refinement now use std::shuffle with a new random generator which will serve the same purpose but may yield altered outputs compared to previous versions due to the differently randomized edges. +``TrapezoidMapTriFinder`` uses different random number generator +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The random number generator used to determine the order of insertion of +triangle edges in ``TrapezoidMapTriFinder`` has changed. This can result in a +different triangle index being returned for a point that lies exactly on an +edge between two triangles. This can also affect triangulation interpolation +and refinement algorithms that use ``TrapezoidMapTriFinder``. From d2d0d11b04b192f46649946745f42517c038de9d Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Fri, 14 Oct 2022 01:47:40 -0400 Subject: [PATCH 08/10] removed random number generator from _tri.h --- src/tri/_tri.h | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/src/tri/_tri.h b/src/tri/_tri.h index 28c8e07933cc..fc3fff7f85bc 100644 --- a/src/tri/_tri.h +++ b/src/tri/_tri.h @@ -790,29 +790,3 @@ class TrapezoidMapTriFinder Node* _tree; // Root node of the trapezoid map search tree. Owned. }; - - - -/* Linear congruential random number generator. Edges in the triangulation are - * randomly shuffled before being added to the trapezoid map. Want the - * shuffling to be identical across different operating systems and the same - * regardless of previous random number use. Would prefer to use a STL or - * Boost random number generator, but support is not consistent across - * different operating systems so implementing own here. - * - * This is not particularly random, but is perfectly adequate for the use here. - * Coefficients taken from Numerical Recipes in C. */ -class RandomNumberGenerator -{ -public: - RandomNumberGenerator(unsigned long seed); - - // Return random integer in the range 0 to max_value-1. - unsigned long operator()(unsigned long max_value); - -private: - const unsigned long _m, _a, _c; - unsigned long _seed; -}; - -#endif From a06bae921506e727d37458de08db2287a0259815 Mon Sep 17 00:00:00 2001 From: tybeller <73607363+tybeller@users.noreply.github.com> Date: Fri, 14 Oct 2022 18:58:32 -0400 Subject: [PATCH 09/10] Update _tri.cpp added empty line at end --- src/tri/_tri.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tri/_tri.cpp b/src/tri/_tri.cpp index 6e639eea44d9..80a14201645b 100644 --- a/src/tri/_tri.cpp +++ b/src/tri/_tri.cpp @@ -2056,4 +2056,4 @@ TrapezoidMapTriFinder::Trapezoid::set_upper_right(Trapezoid* upper_right_) upper_right = upper_right_; if (upper_right != 0) upper_right->upper_left = this; -} \ No newline at end of file +} From 3513a8557959349ce7d042e7717de2c885a0be59 Mon Sep 17 00:00:00 2001 From: Oscar Gustafsson Date: Sun, 23 Oct 2022 18:55:14 +0200 Subject: [PATCH 10/10] Update src/tri/_tri.h --- src/tri/_tri.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/tri/_tri.h b/src/tri/_tri.h index fc3fff7f85bc..29b4ff81fb17 100644 --- a/src/tri/_tri.h +++ b/src/tri/_tri.h @@ -790,3 +790,5 @@ class TrapezoidMapTriFinder Node* _tree; // Root node of the trapezoid map search tree. Owned. }; + +#endif pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy