diff --git a/src/internal/jacobian.jl b/src/internal/jacobian.jl index 46f255149..f34da4868 100644 --- a/src/internal/jacobian.jl +++ b/src/internal/jacobian.jl @@ -99,10 +99,15 @@ function JacobianCache(prob, alg, f::F, fu_, u, p; stats, autodiff = nothing, # While this is technically wasteful, it gives out the type of the Jacobian # which is needed to create the linear solver cache stats.njacs += 1 - if iip - DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p)) + if has_analytic_jac + __similar( + fu, promote_type(eltype(fu), eltype(u)), length(fu), length(u)) else - DI.jacobian(f, autodiff, u, Constant(p)) + if iip + DI.jacobian(f, fu, di_extras, autodiff, u, Constant(p)) + else + DI.jacobian(f, autodiff, u, Constant(p)) + end end else zero(init_jacobian(sdifft_extras; preserve_immutable = Val(true))) diff --git a/test/misc/bruss_tests.jl b/test/misc/bruss_tests.jl index d18c67e6a..8ea1fdb18 100644 --- a/test/misc/bruss_tests.jl +++ b/test/misc/bruss_tests.jl @@ -73,6 +73,6 @@ cache = init( prob_brusselator_2d, NewtonRaphson(; autodiff = AutoSparse(AutoForwardDiff()))) - @test maximum(cache.sdifft_extras.jac_cache.coloring.colorvec) == 12 - @test cache.sdifft_extras.autodiff isa AutoSparse{<:AutoForwardDiff} + @test maximum(cache.jac_cache.sdifft_extras.coloring.colorvec) == 12 + @test cache.jac_cache.autodiff isa AutoSparse{<:AutoForwardDiff} end