Skip to main content

DifferentiableObjective

Trait DifferentiableObjective 

Source
pub trait DifferentiableObjective<T: Float>: Objective<T> + Gradient<T> {
    // Provided method
    fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>) { ... }
}
Expand description

An Objective that can also supply its gradient (natively or via adapter).

There is no blanket impl: a type that is Objective + Gradient must write impl DifferentiableObjective<T> for T { } (empty, default split eval) or override DifferentiableObjective::value_and_gradient for a fused (f, ∇f) that reuses intermediate work (Ceres-style residual + Jacobian in one shot). A blanket impl would make that override E0119.

Provided Methods§

Source

fn value_and_gradient(&self, x: ArrayView1<'_, T>) -> (T, Array1<T>)

Returns (f(x), ∇f(x)). Default calls the two methods separately; analytic implementations should override for efficiency.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§