pub struct Differentiable<V, G> {
pub value: V,
pub derivative: G,
}Expand description
Fields§
§value: V§derivative: GTrait Implementations§
Source§impl<F, E, V: FnMut(&[F], &mut [F]) -> Result<(), E>, G: FnMut(&[F], &[F], &mut [F]) -> Result<(), E>> Mapping<F> for Differentiable<V, G>
impl<F, E, V: FnMut(&[F], &mut [F]) -> Result<(), E>, G: FnMut(&[F], &[F], &mut [F]) -> Result<(), E>> Mapping<F> for Differentiable<V, G>
Source§fn has_vjp(&self) -> bool
fn has_vjp(&self) -> bool
Whether
vjp gives vector–Jacobian products. Least squares in solve_linear needs them.Source§fn vjp(&mut self, u: &[F], x: &[F], out: &mut [F]) -> Result<(), E>
fn vjp(&mut self, u: &[F], x: &[F], out: &mut [F]) -> Result<(), E>
uᵀJ, the product of
u with the Jacobian at x, into out. For a linear mapping it’s the product of the transpose with u, at any x. Methods call it only where has_vjp is true.Source§fn jvp(&mut self, v: &[F], x: &[F], out: &mut [F]) -> Result<bool, Self::Error>
fn jvp(&mut self, v: &[F], x: &[F], out: &mut [F]) -> Result<bool, Self::Error>
Jv, the product of the Jacobian at
x with v, into out. For a linear mapping it’s the product of the matrix with v, at any x. It gives false where it declines, as for a function it can’t differentiate at x, and the caller then takes differences instead. Methods call it only where has_jvp is true.Source§fn jacobian(&mut self, x: &[F], j: &mut [F]) -> Result<bool, Self::Error>where
F: Native,
fn jacobian(&mut self, x: &[F], j: &mut [F]) -> Result<bool, Self::Error>where
F: Native,
The Jacobian at
x, with a row of x.len() items for each value, into j, or false where Levenberg–Marquardt should take forward differences instead. By default, a mapping builds it from vjp, one row per product, when it has no more values than variables or no jvp. Otherwise it builds it from jvp, one column per product. Each takes no more calls than differences do. It gives false for a mapping with neither, or where jvp declines.Source§fn has_preconditioner(&self) -> bool
fn has_preconditioner(&self) -> bool
Whether
precondition gives a preconditioner’s products. solve_linear runs without one otherwise.Source§fn precondition(&mut self, v: &[F], out: &mut [F]) -> Result<(), Self::Error>
fn precondition(&mut self, v: &[F], out: &mut [F]) -> Result<(), Self::Error>
The product with
v of a preconditioner for solve_linear, into out: M, an approximation to the inverse of the matrix, or of AᵀA for least squares. CG and MINRES need M symmetric positive definite. Methods call it only where has_preconditioner is true.Source§impl<F, E, V: FnMut(&[F]) -> Result<F, E>, G: FnMut(&[F], &mut [F]) -> Result<(), E>> Objective<F> for Differentiable<V, G>
impl<F, E, V: FnMut(&[F]) -> Result<F, E>, G: FnMut(&[F], &mut [F]) -> Result<(), E>> Objective<F> for Differentiable<V, G>
Source§type Error = E
type Error = E
What stops an evaluation, such as an error in the caller’s function or an interrupt.
Source§fn has_gradient(&self) -> bool
fn has_gradient(&self) -> bool
Whether
gradient gives the gradient. L-BFGS needs one, and Method::choose picks L-BFGS for an objective that has one.Source§fn gradient(&mut self, x: &[F], g: &mut [F]) -> Result<(), E>
fn gradient(&mut self, x: &[F], g: &mut [F]) -> Result<(), E>
The gradient at
x, into g. Methods call it only where has_gradient is true.Auto Trait Implementations§
impl<V, G> Forget for Differentiable<V, G>
impl<V, G> Freeze for Differentiable<V, G>
impl<V, G> RefUnwindSafe for Differentiable<V, G>where
V: RefUnwindSafe,
G: RefUnwindSafe,
impl<V, G> Send for Differentiable<V, G>
impl<V, G> Sync for Differentiable<V, G>
impl<V, G> Unpin for Differentiable<V, G>
impl<V, G> UnsafeUnpin for Differentiable<V, G>where
V: UnsafeUnpin,
G: UnsafeUnpin,
impl<V, G> UnwindSafe for Differentiable<V, G>where
V: UnwindSafe,
G: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more