Jacobians

The supertype Jacobian comprises different ways of taking Jacobians:

We first start by showing JacobianAutodiff:

# the input and output dimensions of this function are the same
F(y::AbstractArray, x::AbstractArray, params) = y .= tanh.(x)
dim = 3
x = rand(dim)
jac = JacobianAutodiff{eltype(x)}(F, dim)
JacobianAutodiff{Float64, typeof(Main.F), ForwardDiff.JacobianConfig{Nothing, Float64, 3, Tuple{Vector{ForwardDiff.Dual{Nothing, Float64, 3}}, Vector{ForwardDiff.Dual{Nothing, Float64, 3}}}}, Vector{Float64}}(Main.F, ForwardDiff.JacobianConfig{Nothing, Float64, 3, Tuple{Vector{ForwardDiff.Dual{Nothing, Float64, 3}}, Vector{ForwardDiff.Dual{Nothing, Float64, 3}}}}((Partials(1.0, 0.0, 0.0), Partials(0.0, 1.0, 0.0), Partials(0.0, 0.0, 1.0)), (ForwardDiff.Dual{Nothing, Float64, 3}[Dual{Nothing}(6.9282796820863e-310,5.0e-324,6.9281535135182e-310,6.9282138272309e-310), Dual{Nothing}(6.9282881635148e-310,6.92828522414355e-310,6.92815074049534e-310,6.92815348922754e-310), Dual{Nothing}(6.92815351350553e-310,6.9282847526508e-310,6.9281551424787e-310,6.92815351350553e-310)], ForwardDiff.Dual{Nothing, Float64, 3}[Dual{Nothing}(6.9282796820863e-310,6.92821356657925e-310,6.9282916634086e-310,6.92821351323044e-310), Dual{Nothing}(5.0e-324,1.94647e-319,2.130317216e-314,7.746817145885188e-304), Dual{Nothing}(5.0e-324,6.9282839241177e-310,6.92815569608913e-310,6.92821351322333e-310)])), [0.0, 0.0, 0.0])

And the functor:

j = zeros(3, 3)
jac(j, x, nothing)
3×3 Matrix{Float64}:
 0.770907  0.0       0.0
 0.0       0.721643  0.0
 0.0       0.0       0.493302