Struct newton_rootfinder::model::UserModelFromFunction[][src]

pub struct UserModelFromFunction {
    pub inputs: DVector<f64>,
    pub func: fn(_: &DVector<f64>) -> DVector<f64>,
    pub left: DVector<f64>,
    pub right: DVector<f64>,
    // some fields omitted
}
Expand description

Blanket implementation to easily adapt user function 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

pub fn square(x: &nalgebra::DVector::<f64>) -> nalgebra::DVector::<f64> {
    x*x
}

use newton_rootfinder as nrf;
use nrf::model::Model; // trait import required

let iteratives = nalgebra::DVector::from_vec(vec!(2.0));
let mut user_model = nrf::model::UserModelFromFunction::new(1, square);
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>func: fn(_: &DVector<f64>) -> DVector<f64>left: DVector<f64>right: DVector<f64>

Implementations

Trait Implementations

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

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.