Struct newton_rootfinder::model::UserModelFromClosure [−][src]
pub struct UserModelFromClosure<'a> {
pub inputs: DVector<f64>,
pub closure: &'a dyn Fn(&DVector<f64>) -> DVector<f64>,
pub left: DVector<f64>,
pub right: DVector<f64>,
// some fields omitted
}
Expand description
Blanket implementation to easily adapt user closure to the Model trait required by the solver to work with finite-differences
The right side of the equation is a constant and by default zero. No other outputs are computed
Examples
use newton_rootfinder as nrf;
use nrf::model::Model; // trait import required
let square_closure = |iteratives: &nalgebra::DVector<f64>| -> nalgebra::DVector<f64> {
iteratives * iteratives
};
let iteratives = nalgebra::DVector::from_vec(vec!(2.0));
let mut user_model = nrf::model::UserModelFromClosure::new(1, &square_closure);
user_model.set_iteratives(&iteratives);
user_model.evaluate();
assert_eq!(user_model.len_problem(), 1);
assert_eq!(user_model.get_iteratives(), nalgebra::DVector::from_vec(vec!(2.0)));
assert_eq!(user_model.jacobian_provided(), false);
assert_eq!(user_model.get_residuals().get_values(0), (4.0, 0.0));
Fields
inputs: DVector<f64>
closure: &'a dyn Fn(&DVector<f64>) -> DVector<f64>
left: DVector<f64>
right: DVector<f64>
Implementations
Trait Implementations
type InaccurateValuesError = Infallible
type UnusableValuesError = Infallible
This method should update the values of the outputs of the model by using as inputs the values set by the Model::set_iteratives method. Read more
This method gets the values of the output for the solver. The return argument is in a specific format, separating left and right member of an equation. Read more
This method is required to access the values of the iteratives variables during the resolution process. The values returned should be the same one as the one set by the Model::set_iteratives method. Read more
This method provides the solver a mecanism to set the iteratives values and perform the resolution
This method defines the dimension of the problem. Read more
This method allows the solver to know if the jacobian is provided by the user or not Read more
Method allowing to access the jacobian matrix This method takes a mutable model, as it allows to compute the jacobian when needed and not only when the model is evaluated. Read more
This method allow the solver to memorize information after calculating the reference point and before the jacobian evaluation by finite-difference. Read more
This method is called in-between the computation of each column of the jacobian matrix, in order to reset the values to the ones from the Model::get_memory Read more
Auto Trait Implementations
impl<'a> !RefUnwindSafe for UserModelFromClosure<'a>
impl<'a> !Send for UserModelFromClosure<'a>
impl<'a> !Sync for UserModelFromClosure<'a>
impl<'a> Unpin for UserModelFromClosure<'a>
impl<'a> !UnwindSafe for UserModelFromClosure<'a>
Blanket Implementations
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.