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.9013628700468e-310,6.90129712383843e-310,6.90137485928684e-310,6.9013609715545e-310), Dual{Nothing}(9.0794e-320,1.94647e-319,2.130317216e-314,7.746817145885188e-304), Dual{Nothing}(5.0e-324,6.9013671504952e-310,6.90132520345546e-310,6.9013609715474e-310)], ForwardDiff.Dual{Nothing, Float64, 3}[Dual{Nothing}(8.4e-323,9.0e-323,9.4e-323,1.24e-322), Dual{Nothing}(1.3e-322,1.33e-322,1.63e-322,1.7e-322), Dual{Nothing}(1.73e-322,2.03e-322,2.08e-322,2.1e-322)])), [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