Skip to content

Commit facf227

Browse files
committed
Safely initialize the inplace Jacobian cache
This fixes support for BigFloat in LsqFit.jl, ForwardDiff.jl requires that the array is initialized.
1 parent fa8b3bc commit facf227

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/objective_types/oncedifferentiable.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ function OnceDifferentiable(f, x_seed::AbstractArray, F::AbstractArray, DF::Abst
7979
return OnceDifferentiable(fF, dfF, fdfF, x_seed, F, DF)
8080
else
8181
F2 = similar(F)
82+
# Note that we fill the array to ensure that no elements are
83+
# uninitialized, e.g. in the case of BigFloat which is not an isbits
84+
# type. ForwardDiff requires that the array is fully initialized:
85+
# https://github.com/JuliaDiff/ForwardDiff.jl/issues/740
86+
fill!(F2, zero(eltype(F2)))
87+
8288
backend = get_adtype(autodiff, chunk)
8389
jac_prep = DI.prepare_jacobian(f, F2, backend, x_seed)
8490
function j!(_j, _x)

0 commit comments

Comments
 (0)