Skip to content
This repository was archived by the owner on Aug 22, 2025. It is now read-only.

Commit 8dc0db0

Browse files
committed
Add dx back as keyword even if using oop f with pre-allocated Jacobian.
1 parent de7aa2b commit 8dc0db0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/differentiation/compute_jacobian_ad.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ end
8383
colorvec = 1:length(x),
8484
sparsity = nothing,
8585
jac_prototype = nothing,
86-
chunksize = nothing) # Note no dx keyword b/c can infer Jacobian's size via J
86+
chunksize = nothing,
87+
dx = similar(x, size(J, 1))) #if dx is nothing, we will estimate dx at the cost of a function call
8788
if sparsity === nothing && jac_prototype === nothing || !ArrayInterface.ismutable(x)
8889
cfg = chunksize === nothing ? ForwardDiff.JacobianConfig(f, x) : ForwardDiff.JacobianConfig(f, x, ForwardDiff.Chunk(getsize(chunksize)))
8990
return ForwardDiff.jacobian(f, x, cfg)
9091
end
91-
forwarddiff_color_jacobian(J,f,x,ForwardColorJacCache(f,x,chunksize,dx=similar(x,size(J, 1)),colorvec=colorvec,sparsity=sparsity),jac_prototype)
92+
forwarddiff_color_jacobian(J,f,x,ForwardColorJacCache(f,x,chunksize,dx=dx,colorvec=colorvec,sparsity=sparsity),jac_prototype)
9293
end
9394

9495
function forwarddiff_color_jacobian(f,x::AbstractArray{<:Number},jac_cache::ForwardColorJacCache,jac_prototype=nothing)

0 commit comments

Comments
 (0)