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}(5.0e-324,1.5e-323,6.951731224553e-310,6.9517312245546e-310), Dual{Nothing}(0.0,0.0,0.0,0.0), Dual{Nothing}(0.0,0.0,0.0,0.0)], ForwardDiff.Dual{Nothing, Float64, 3}[Dual{Nothing}(6.95169866183727e-310,6.95169866183885e-310,6.95169866184044e-310,6.951698661842e-310), Dual{Nothing}(6.9516986618436e-310,6.9516986618452e-310,6.95169866184676e-310,6.95169866184834e-310), Dual{Nothing}(6.9516986618499e-310,6.9516986618515e-310,6.9516986618531e-310,6.95176679882574e-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