pub fn default_with_guess<'a, T, D>(
    initial_guess: OVector<f64, D>,
    iters_params: &'a Iteratives<'a, T>,
    residuals_config: &'a ResidualsConfig<'a>,
    resolution_method: ResolutionMethod,
    damping: bool
) -> RootFinder<'a, T, D>where
    T: Iterative + Display + Debug,
    D: DimMin<D, Output = D>,
    DefaultAllocator: Allocator<f64, D>,
    DefaultAllocator: Allocator<f64, U1, D>,
    DefaultAllocator: Allocator<f64, D, D>,
    DefaultAllocator: Allocator<(usize, usize), D>,
Expand description

Default function to create a solver with default parameters

The default parameters are:

  • max_iter = 50
  • tolerance = 1e-6
  • resolution_method = NewtonRaphson
  • damping = false

This function works either for finite difference or not.

The difference between the two cases comes from the construction of the vector of iteratives parameters Either with default_vec_iteratives_fd() or default_vec_iteratives()

It is required to create the vector in the scope of the calling function as Iteratives::new() takes as argument a reference to a slice

This allows to of the iteratives variables defined either :

  • at compile-time (through an array)
  • at run-time (through the generation of a vector while parsing a configuration file)

Examples

use newton_rootfinder as nrf;
use nrf::iteratives;
use nrf::residuals;
use nrf::solver::ResolutionMethod;


fn main() {
  let problem_size = 1;
  let init_guess_fd = nalgebra::DVector::from_vec(vec![1.0]);
  let vec_iter_params_fd = iteratives::default_vec_iteratives_fd(problem_size);
  let iter_params_fd = iteratives::Iteratives::new(&vec_iter_params_fd);
  let stopping_residuals_fd = vec![residuals::NormalizationMethod::Abs; problem_size];
  let update_methods_fd = vec![residuals::NormalizationMethod::Abs; problem_size];
  let res_config_fd = residuals::ResidualsConfig::new(&stopping_residuals_fd, &update_methods_fd);

  let init_guess = nalgebra::DVector::from_vec(vec![1.0]);
  let vec_iter_params = iteratives::default_vec_iteratives(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_fd = nrf::solver::default_with_guess(init_guess_fd, &iter_params_fd, &res_config_fd, ResolutionMethod::NewtonRaphson, damping);
  let mut rf = nrf::solver::default_with_guess(init_guess, &iter_params, &res_config, ResolutionMethod::NewtonRaphson, damping);
}