Struct optimization::NumericalDifferentiation
[−]
[src]
pub struct NumericalDifferentiation<F: Function> { // some fields omitted }
Wraps a function for which to provide numeric differentiation.
Uses simple one step forward finite difference with step width h = √εx
.
Examples
let square = NumericalDifferentiation::new(Func(|x: &[f64]| { x[0] * x[0] })); assert!(square.gradient(&[0.0])[0] < 1.0e-3); assert!(square.gradient(&[1.0])[0] > 1.0); assert!(square.gradient(&[-1.0])[0] < 1.0);
Methods
impl<F: Function> NumericalDifferentiation<F>
fn new(function: F) -> Self
Creates a new differentiable function by using the supplied function
in
combination with numeric differentiation to find the derivatives.