oop jacobian can't preserve array-like objects
forwarddiff_color_jacobian automatically converts array-like input object into array. When f depend on specific property of the input object, the jacobian will fail. MWE:
using OrdinaryDiffEq, SparseDiffTools
mutable struct SimTypeg{T,T2} <: DEDataMatrix{T}
x::Array{T,2} # two dimensional
f1::T2
end
function f(u)
u.f1*u[1]
end
u0 = SimTypeg(fill(0.00001,2,2),0.0)
forwarddiff_color_jacobian(f,u0)
Does it also convert SArrays?
No, because vec(x) keeps SArray. https://github.com/JuliaDiffEq/SparseDiffTools.jl/blob/aaaa9048de136cf222967d3f4c5d13315cbf9208/src/differentiation/compute_jacobian_ad.jl#L102
Does this at least not break anything that currently exists?
Does this at least not break anything that currently exists?
It break at least one test in OrdinaryDiffEq.jl: https://github.com/JuliaDiffEq/OrdinaryDiffEq.jl/blob/master/test/interface/data_array_test.jl
Looks like there's a few other things to work out with resizing.