Struct newton_rootfinder::iteratives::IterativeParams
source · [−]pub struct IterativeParams { /* private fields */ }
Expand description
The parameters of an iterative variable
This parameters are used by the step_limitation()
method from the Iterative
trait to reduce the size of a step
Implementations
sourceimpl IterativeParams
impl IterativeParams
sourcepub fn new(
max_step_abs: f64,
max_step_rel: f64,
min_value: f64,
max_value: f64
) -> Self
pub fn new(
max_step_abs: f64,
max_step_rel: f64,
min_value: f64,
max_value: f64
) -> Self
The parameters are used by the step_limitation()
method from the Iterative
trait to reduce the size of a step
Both value max_step_abs
and max_step_rel
must be positive
The min_value
must be lower than the max_value
pub fn get_min_value(&self) -> f64
pub fn get_max_value(&self) -> f64
pub fn get_max_step_abs(&self) -> f64
pub fn get_max_step_rel(&self) -> f64
Trait Implementations
sourceimpl Clone for IterativeParams
impl Clone for IterativeParams
sourcefn clone(&self) -> IterativeParams
fn clone(&self) -> IterativeParams
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresourceimpl Debug for IterativeParams
impl Debug for IterativeParams
sourceimpl Default for IterativeParams
impl Default for IterativeParams
sourcefn default() -> IterativeParams
fn default() -> IterativeParams
Returns the “default value” for a type. Read more
sourceimpl Display for IterativeParams
impl Display for IterativeParams
sourceimpl Iterative for IterativeParams
impl Iterative for IterativeParams
sourcefn step_limitation(&self, value_current: f64, raw_step: f64) -> f64
fn step_limitation(&self, value_current: f64, raw_step: f64) -> f64
Compute a limited update step
The step size is reduced according to the following criteria :
abs(step_size) < max_step_abs
abs(step_size) < max_step_rel*abs(iterative_value)
Also, the step must not violated the constraints on the min_value
and max_value
of the iterative variable.
Warning: setting the parameters max_step_rel to a value different from infinity might lead to very reduced step size if the iterative value is near zero.
Examples
use newton_rootfinder as nrf;
use nrf::iteratives::*;
let (max_step_abs, max_step_rel, min_value, max_value) = (1.0, 1.0, f64::NEG_INFINITY, f64::INFINITY);
let mut iterative_var = IterativeParams::new(max_step_abs, max_step_rel, min_value, max_value);
assert_eq!(iterative_var.step_limitation(1.0, 1.0), 2.0);
assert_eq!(iterative_var.step_limitation(1.0, 3.0), 2.0);
let (max_step_abs, max_step_rel, min_value, max_value) = (0.1, 0.5, f64::NEG_INFINITY, f64::INFINITY);
let mut iterative_var = IterativeParams::new(max_step_abs, max_step_rel, min_value, max_value);
assert_eq!(iterative_var.step_limitation(1.5, 0.5), 1.6);
assert_eq!(iterative_var.step_limitation(0.1, 3.0), 0.15000000000000002);
sourcefn compute_perturbation(&self, x: f64) -> f64
fn compute_perturbation(&self, x: f64) -> f64
Compute the perturbation (only valid if it is working with finite differences) Read more
sourcefn with_finite_diff(&self) -> bool
fn with_finite_diff(&self) -> bool
Method to differente without panicking if it is working with finite differences
sourceimpl PartialEq<IterativeParams> for IterativeParams
impl PartialEq<IterativeParams> for IterativeParams
sourcefn eq(&self, other: &IterativeParams) -> bool
fn eq(&self, other: &IterativeParams) -> bool
impl StructuralPartialEq for IterativeParams
Auto Trait Implementations
impl RefUnwindSafe for IterativeParams
impl Send for IterativeParams
impl Sync for IterativeParams
impl Unpin for IterativeParams
impl UnwindSafe for IterativeParams
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read morefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.