jacobian

Function jacobian 

Source
pub fn jacobian<G, T: DualNum<F>, F: DualNumFloat, M: Dim, N: Dim, O: Mappable<OVector<DualVec<T, F, N>, M>>>(
    g: G,
    x: &OVector<T, N>,
) -> O::Output<(OVector<T, M>, OMatrix<T, M, N>)>
where G: FnOnce(OVector<DualVec<T, F, N>, N>) -> O, DefaultAllocator: Allocator<M> + Allocator<N> + Allocator<M, N> + Allocator<U1, N>,
Expand description

Calculate the Jacobian of a vector function.

let xy = SVector::from([5.0, 3.0, 2.0]);
let fun = |xy: SVector<DualSVec64<3>, 3>| SVector::from([
                     xy[0] * xy[1].powi(3) * xy[2],
                     xy[0].powi(2) * xy[1] * xy[2].powi(2)
                    ]);
let (f, jac) = jacobian(fun, &xy);
assert_eq!(f[0], 270.0);          // xy³z
assert_eq!(f[1], 300.0);          // x²yz²
assert_eq!(jac[(0,0)], 54.0);     // y³z
assert_eq!(jac[(0,1)], 270.0);    // 3xy²z
assert_eq!(jac[(0,2)], 135.0);    // xy³
assert_eq!(jac[(1,0)], 120.0);    // 2xyz²
assert_eq!(jac[(1,1)], 100.0);    // x²z²
assert_eq!(jac[(1,2)], 300.0);     // 2x²yz