Skip to content

Commit

Permalink
avoid multiple copies in lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Oct 5, 2016
1 parent b198cd4 commit db9d9cd
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions templates/mass_eigenstates.cpp.in
Expand Up @@ -353,18 +353,19 @@ void CLASSNAME::set_ewsb_solution(const EWSB_solver* solver)
template <typename It>
void CLASSNAME::set_best_ewsb_solution(It first, It last)
{
const auto best_solver =
std::min_element(first, last,
[this](const std::unique_ptr<EWSB_solver>& a, const std::unique_ptr<EWSB_solver>& b) {
CLASSNAME ma(*this), mb(*this);
ma.set_ewsb_solution(a.get());
mb.set_ewsb_solution(b.get());
return Total(Abs(Re(ma.tadpole_equations()))) < Total(Abs(Re(mb.tadpole_equations())));
});

VERBOSE_MSG("\tUsing best solution from " << (*best_solver)->name());

set_ewsb_solution(best_solver->get());
CLASSNAME ma(*this), mb(*this);

const auto best_solver =
std::min_element(first, last,
[this, &ma, &mb](const std::unique_ptr<EWSB_solver>& a, const std::unique_ptr<EWSB_solver>& b) {
ma.set_ewsb_solution(a.get());
mb.set_ewsb_solution(b.get());
return Total(Abs(Re(ma.tadpole_equations()))) < Total(Abs(Re(mb.tadpole_equations())));
});

VERBOSE_MSG("\tUsing best solution from " << (*best_solver)->name());

set_ewsb_solution(best_solver->get());
}

int CLASSNAME::solve_ewsb_iteratively(unsigned loop_order)
Expand Down

0 comments on commit db9d9cd

Please sign in to comment.