Skip to content

Commit

Permalink
try all root-finding algorithms
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Jul 18, 2015
1 parent 02b97e5 commit 635a482
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
11 changes: 3 additions & 8 deletions src/root_solver.cpp
Expand Up @@ -89,16 +89,11 @@ void RGFlow<Root>::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<ERootFinder_t>(i));
}

Expand Down
6 changes: 2 additions & 4 deletions src/root_solver.hpp
Expand Up @@ -56,10 +56,8 @@ template<>
class RGFlow<Root> {
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();
Expand Down

0 comments on commit 635a482

Please sign in to comment.