summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-14 11:07:35 -0500
committerJaron Kent-Dobias <jaron@kent-dobias.com>2019-12-14 11:07:35 -0500
commita1b737c049bb297d5e4ec80cd5335d1382ce623a (patch)
tree13520d1bc948fe1c0f89f79b035cc6fb010da1bc
parenta75a3b44ffe9c99fc6d1c07ba4c4542b85f02790 (diff)
downloadc++-a1b737c049bb297d5e4ec80cd5335d1382ce623a.tar.gz
c++-a1b737c049bb297d5e4ec80cd5335d1382ce623a.tar.bz2
c++-a1b737c049bb297d5e4ec80cd5335d1382ce623a.zip
efficiency tuning: don't evaluate the exponential when we don't have to
-rw-r--r--lib/wolff.hpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/wolff.hpp b/lib/wolff.hpp
index d21d788..23df10c 100644
--- a/lib/wolff.hpp
+++ b/lib/wolff.hpp
@@ -239,7 +239,11 @@ namespace wolff{
}
#ifndef WOLFF_USE_FINITE_STATES
- p = 1.0 - exp(-dE / T);
+ if (dE < 0) {
+ p = 0;
+ } else {
+ p = 1.0 - exp(-dE / T);
+ }
#endif
if (dist(rng) < p) {