summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/include/network.hpp1
-rw-r--r--lib/src/network.cpp10
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/include/network.hpp b/lib/include/network.hpp
index 849975f..d955e43 100644
--- a/lib/include/network.hpp
+++ b/lib/include/network.hpp
@@ -5,6 +5,7 @@
#include <functional>
#include <utility>
#include <random>
+#include <limits>
#include <cholmod.h>
diff --git a/lib/src/network.cpp b/lib/src/network.cpp
index bc7a0c6..9cb1007 100644
--- a/lib/src/network.cpp
+++ b/lib/src/network.cpp
@@ -89,10 +89,10 @@ void network::set_thresholds(double beta, std::mt19937& rng) {
std::uniform_real_distribution<long double> d(0.0, 1.0);
for (long double& threshold : thresholds) {
- threshold = 0.0;
+ threshold = std::numeric_limits<long double>::lowest();
- while (threshold == 0.0) {
- threshold = expl(logl(d(rng)) / (long double)beta);
+ while (threshold == std::numeric_limits<long double>::lowest()) {
+ threshold = logl(d(rng)) / (long double)beta;
}
}
}
@@ -202,11 +202,11 @@ void network::fracture(hooks& m, double cutoff) {
}
unsigned int max_pos = UINT_MAX;
- long double max_val = 0;
+ long double max_val = std::numeric_limits<long double>::lowest();
for (unsigned int i = 0; i < G.edges.size(); i++) {
if (!fuses[i] && fabs(ci.currents[i]) > cutoff) {
- long double val = (long double)fabs(ci.currents[i]) / thresholds[i];
+ long double val = logl(fabs(ci.currents[i])) - thresholds[i];
if (val > max_val) {
max_val = val;
max_pos = i;