diff options
author | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-12-14 11:07:35 -0500 |
---|---|---|
committer | Jaron Kent-Dobias <jaron@kent-dobias.com> | 2019-12-14 11:07:35 -0500 |
commit | a1b737c049bb297d5e4ec80cd5335d1382ce623a (patch) | |
tree | 13520d1bc948fe1c0f89f79b035cc6fb010da1bc | |
parent | a75a3b44ffe9c99fc6d1c07ba4c4542b85f02790 (diff) | |
download | c++-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.hpp | 6 |
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) { |