Module newton_rootfinder::solver [−][src]
Expand description
Solver configuration
The solver is defined in the RootFinder
struct.
To create a new solver, it is required to give the 4 following:
- The parameters through the
SolverParameters
struct - The iteratives configuration through a reference to a slice of
Iteratives
- The residuals configuration through a reference to a slice of
ResidualsConfig
- The initial guess to use by the solver
Features
- Simulation log available for debugging, check the
set_debug()
method - Damping, check the
set_damping()
method
Examples
use newton_rootfinder as nrf;
use nrf::model::Model;
use nrf::iteratives;
use nrf::residuals;
use nrf::solver::ResolutionMethod;
/// Equation : x**2 - 2 = 0
fn square2(x: &nalgebra::DVector<f64>) -> nalgebra::DVector<f64> {
let mut y = x * x;
y[0] -= 2.0;
y
}
fn main() {
let problem_size = 1;
let init_guess = nalgebra::DVector::from_vec(vec![1.0]);
let vec_iter_params = iteratives::default_vec_iteratives_fd(problem_size);
let iter_params = iteratives::Iteratives::new(&vec_iter_params);
let stopping_residuals = vec![residuals::NormalizationMethod::Abs; problem_size];
let update_methods = vec![residuals::NormalizationMethod::Abs; problem_size];
let res_config = residuals::ResidualsConfig::new(&stopping_residuals, &update_methods);
let damping = false;
let mut rf = nrf::solver::default_with_guess(init_guess, &iter_params, &res_config, ResolutionMethod::NewtonRaphson, damping);
let mut user_model =
nrf::model::UserModelFromFunction::new(problem_size, square2);
rf.solve(&mut user_model).unwrap();
println!("{}", user_model.get_iteratives()[0]);
// print 1.4142135623747443
}
Structs
Solver for rootfinding
A minimal struct holding the resolution parameters
Enums
Quasi-Newton methods are less computationnaly expensive than the Newton-Raphson method.
Choice of the iterative algorithm for the resolution
This quasi-Newton methods either work on the jacobian or its inverse
Functions
Broyden first method update formula
Broyden first method update formula
Broyden Second method update formula
Broyden second method update formula
Evaluate a jacobian per forward finite difference when perturbation step eps is provided
Default function to create a solver with default parameters
Greenstadt second method update formula
Generic function for quasi method update. This implements Spedicato’s formula. To be used when no formula simplification can be done before implementation
Generic function for quasi method update. This implements Spedicato’s formula. To be used when no formula simplification can be done before implementation