pub fn jacobian<G, T: DualNum<F>, F: DualNumFloat, M: Dim, N: Dim>(
g: G,
x: OVector<T, N>
) -> (OVector<T, M>, OMatrix<T, M, N>)where
G: FnOnce(OVector<DualVec<T, F, N>, N>) -> OVector<DualVec<T, F, N>, M>,
DefaultAllocator: Allocator<DualVec<T, F, N>, M> + Allocator<T, M> + Allocator<T, N> + Allocator<T, M, N> + Allocator<T, Const<1>, N> + Allocator<DualVec<T, F, N>, N> + Allocator<OMatrix<T, U1, N>, M>,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