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.

Trait Implementations

impl<F: Function> Function for NumericalDifferentiation<F>

fn value(&self, position: &[f64]) -> f64

impl<F: Function> Function1 for NumericalDifferentiation<F>

fn gradient(&self, position: &[f64]) -> Vec<f64>

impl<F: Function + Default> Default for NumericalDifferentiation<F>

fn default() -> Self

impl<F: Problem> Problem for NumericalDifferentiation<F>

fn dimensions(&self) -> usize

fn domain(&self) -> Vec<(f64, f64)>

fn minimum(&self) -> (Vec<f64>, f64)

fn random_start(&self) -> Vec<f64>