diff --git a/triqs/mc_tools/mc_move_set.hpp b/triqs/mc_tools/mc_move_set.hpp index 43178a7b..fcfb7967 100644 --- a/triqs/mc_tools/mc_move_set.hpp +++ b/triqs/mc_tools/mc_move_set.hpp @@ -183,16 +183,22 @@ namespace triqs { namespace mc_tools { std::cerr <<" Proposition probability = "<attempt(); - if (!std::isfinite(std::abs(rate_ratio))) - TRIQS_RUNTIME_ERROR<<"Monte Carlo Error : the rate is not finite in move "<1 for metropolis + try_sign_ratio = (std::signbit(rate_ratio) ? -1 : 1); // signbit -> true iif the number is negative + } else { + if (!std::isfinite(std::abs(rate_ratio))) + TRIQS_RUNTIME_ERROR << "Monte Carlo Error : the rate is not finite in move " << name_of_currently_selected(); + abs_rate_ratio = std::abs(rate_ratio); #ifdef TRIQS_TOOLS_MC_DEBUG - std::cerr << " Metropolis ratio " << rate_ratio<<". Abs(Metropolis ratio) " <=0)); - try_sign_ratio = ( abs_rate_ratio> 1.e-14 ? rate_ratio/abs_rate_ratio : 1); // keep the sign - return abs_rate_ratio; + assert((abs_rate_ratio >= 0)); + try_sign_ratio = (abs_rate_ratio > 1.e-14 ? rate_ratio / abs_rate_ratio : 1); // keep the sign } + return abs_rate_ratio; + } /** * accept the move previously selected and tried.