From 635a4827754cdf4d6530b6edf864d67559a4cb2b Mon Sep 17 00:00:00 2001 From: Alexander Voigt Date: Sat, 18 Jul 2015 15:48:59 +0200 Subject: [PATCH] try all root-finding algorithms --- src/root_solver.cpp | 11 +++-------- src/root_solver.hpp | 6 ++---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/root_solver.cpp b/src/root_solver.cpp index 918817d3e..d5d288ebc 100644 --- a/src/root_solver.cpp +++ b/src/root_solver.cpp @@ -89,16 +89,11 @@ void RGFlow::solve() if (models.empty() || max_iterations == 0) return; - // try the following algorithms - ERootFinder_t algorithms[] = { Hybrid// , HybridS - }; - int status = GSL_CONTINUE; - initial_guess(); - - for (unsigned i = 0; i < sizeof(algorithms)/sizeof(*algorithms) - && status != GSL_SUCCESS; i++) { + for (unsigned i = 0; i < NUMBER_OF_ROOT_FINDERS && status != GSL_SUCCESS; + i++) { + initial_guess(); status = find_root(static_cast(i)); } diff --git a/src/root_solver.hpp b/src/root_solver.hpp index c0809b834..29afb2b4a 100644 --- a/src/root_solver.hpp +++ b/src/root_solver.hpp @@ -56,10 +56,8 @@ template<> class RGFlow { public: - /// Note: The Newton and Broyden algorithms will not work if some - /// model parameters are identically zero, as this will lead to a - /// non-invertible Jakobian matrix. - enum ERootFinder_t { Hybrid, HybridS, Broyden, Newton }; + enum ERootFinder_t { Hybrid, HybridS, Broyden, Newton, + NUMBER_OF_ROOT_FINDERS }; RGFlow(); ~RGFlow();