From f861195c1416220c4039bda4d1cbf8c3aab07528 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Sun, 24 Feb 2019 17:19:52 -0500 Subject: added support for specifiying voronoi graphs with number of points and aspect ratio, and added support for "infinite" beta (everything has the some threshold) --- lib/src/network.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/src/network.cpp') diff --git a/lib/src/network.cpp b/lib/src/network.cpp index 027946a..43b0fab 100644 --- a/lib/src/network.cpp +++ b/lib/src/network.cpp @@ -95,13 +95,20 @@ network::~network() { } void network::set_thresholds(double beta, std::mt19937& rng) { - std::uniform_real_distribution d(0.0, 1.0); + if (beta == 0.0) { + /* zero beta doesn't make any sense computationally, we interpret it as "infinity" */ + for (long double& threshold : thresholds) { + threshold = 1.0; + } + } else { + std::uniform_real_distribution d(0.0, 1.0); - for (long double& threshold : thresholds) { - threshold = std::numeric_limits::lowest(); + for (long double& threshold : thresholds) { + threshold = std::numeric_limits::lowest(); - while (threshold == std::numeric_limits::lowest()) { - threshold = logl(d(rng)) / (long double)beta; + while (threshold == std::numeric_limits::lowest()) { + threshold = logl(d(rng)) / (long double)beta; + } } } } -- cgit v1.2.3-70-g09d2