gradient_result
Stable type · Replay and adjoint
Tier: stable · Kind: type · Topic: Replay and adjoint
| Julia | Rust |
|---|---|
| not exported | adjoint::Gradient |
Julia
Julia does not export this type.
Rust
pub struct Gradient {
pub functional: f64,
pub u0: Vec<f64>,
pub p: Vec<f64>,
}
The functional and its gradient.
Example (gradient)
let g = spec.gradient(&fwd, &p).unwrap();
// The functional is u(2), so ∂J/∂u0 is d u(2) / d u(0) = exp(-k t).
assert!((g.u0[0] - (-k * 2.0).exp()).abs() < 1e-4 * (-k * 2.0).exp());
assert_eq!(g.p.len(), p.len());