pub struct NumericalDifferentiation<F: Function> { /* private fields */ }
Expand description
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);
Implementations§
Trait Implementations§
Source§impl<F: Function> Function for NumericalDifferentiation<F>
impl<F: Function> Function for NumericalDifferentiation<F>
Source§impl<F: Function> Function1 for NumericalDifferentiation<F>
impl<F: Function> Function1 for NumericalDifferentiation<F>
Source§impl<F: Problem> Problem for NumericalDifferentiation<F>
impl<F: Problem> Problem for NumericalDifferentiation<F>
Source§fn dimensions(&self) -> usize
fn dimensions(&self) -> usize
Returns the dimensionality of the input domain.
Source§fn domain(&self) -> Vec<(f64, f64)>
fn domain(&self) -> Vec<(f64, f64)>
Returns the input domain of the function in terms of upper and lower,
respectively, for each input dimension.
Source§fn minimum(&self) -> (Vec<f64>, f64)
fn minimum(&self) -> (Vec<f64>, f64)
Returns the position as well as the value of the global minimum.
Source§fn random_start(&self) -> Vec<f64>
fn random_start(&self) -> Vec<f64>
Generates a random and feasible position to start a minimization.
Source§fn is_legal_position(&self, position: &[f64]) -> bool
fn is_legal_position(&self, position: &[f64]) -> bool
Tests whether the supplied position is legal for this function.
Auto Trait Implementations§
impl<F> Freeze for NumericalDifferentiation<F>where
F: Freeze,
impl<F> RefUnwindSafe for NumericalDifferentiation<F>where
F: RefUnwindSafe,
impl<F> Send for NumericalDifferentiation<F>where
F: Send,
impl<F> Sync for NumericalDifferentiation<F>where
F: Sync,
impl<F> Unpin for NumericalDifferentiation<F>where
F: Unpin,
impl<F> UnwindSafe for NumericalDifferentiation<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more