mod autodiff¶
- module autodiff¶
Forward-mode automatic differentiation via
num-dual. Forward-mode automatic differentiation vianum-dual.Write the scalar field once, generic over
num_dual::DualNum. This module lifts it toObjective+Gradient+DifferentiableObjectivewith a fusedvalue_and_gradient(one dual evaluation, exact partials). Central differences stay available ascrate::FiniteDiffGradientwhen the function cannot be instantiated at a dual type.Traits
- trait DualField¶
A scalar field R^n -> R written generically over dual numbers.
Functions
- fn eval_dual<D: DualNum<f64> + Clone>(&self, x: &[D]) -> D¶
Evaluates
fatx. Instantiated atf64for values and atDualDVec64for an exact gradient in one sweep.
Structs and Unions
- struct ForwardAd<S: DualField>¶
Forward-mode AD wrapper around a
DualField.Implementations
- impl<S: DualField> ForwardAd<S>¶
Functions
- fn value_and_grad(&self, x: ArrayView1<f64>) -> (f64, Array1<f64>)¶
Exact
(f, ∇f)atxfrom one dual evaluation.
Traits implemented
- impl<S: DualField> DifferentiableObjective<f64> for ForwardAd<S>¶