14#ifndef ROOT_SOLVER_DEF_HPP
15#define ROOT_SOLVER_DEF_HPP
18#include <Eigen/Sparse>
39 std::function<double(
double)>
43 std::function<double(
double)>
58 void save_results(
int iter, Eigen::Vector2d result_to_save);
115 Eigen::MatrixX2d
solve();
Definition solver_tester.hpp:10
Class Solver managing the solving process and creating the Stepper object.
Definition solver_def.hpp:31
double tolerance
Stores the tolerance below which the process ends.
Definition solver_def.hpp:36
void save_results(int iter, Eigen::Vector2d result_to_save)
Saves the result of a step in a defined row of the results' matrix.
Definition solver.hpp:78
int max_iterations
Stores the maximum iterations for the method.
Definition solver_def.hpp:35
Eigen::MatrixX2d solve()
Calls everything required to Solve with a method.
Definition solver.hpp:108
void save_starting_point()
Saves the actual initial guess in the top row of the results' matrix, no matter what type will be the...
void convert_stepper(std::unique_ptr< StepperBase< T > > &stepper)
Converts the generic Abstract stepper into a typed one.
bool aitken_requirement
True if Aitken acceleration is required, 0 otherwise.
Definition solver_def.hpp:37
std::function< double(double)> function
Stores the function to find the root of and the starting guess for the process.
Definition solver_def.hpp:44
std::function< double(double)> derivative_or_function_g
Stores the derivative or g_function of the function if needed.
Definition solver_def.hpp:40
void solver_step(int &iter, std::unique_ptr< StepperBase< T > > &stepper, double &err)
Creates the stepper, calls the step computation, the error calculation and the results' saver.
Definition solver.hpp:149
Eigen::Vector2d get_previous_result(int step_length)
Returns a row of the results' matrix.
Definition solver.hpp:84
bool verbose
Verbose mode flag.
Definition solver_def.hpp:38
Eigen::MatrixX2d results
Definition solver_def.hpp:41
T initial_guess
Templated initial_guess for the method, whose type changes depending on the method itself.
Definition solver_def.hpp:45
double calculate_error(double x_prev, double x_next)
Computes the error of the latest iteration.
Definition solver.hpp:103
Method method
Method which will be used - defined thanks to.
Definition solver_def.hpp:34
The virtual mother stepper class which defines constructor and method in common for all the methods.
Definition stepper_def.hpp:24
Method
Enumeration of available root-finding methods.
Definition method.hpp:8
Contains definitions for all the Classes Stepper to compute steps of numerical methods to find the ro...