diff --git a/src/differentiation/compute_jacobian_ad.jl b/src/differentiation/compute_jacobian_ad.jl index 1a954cfe..45148f44 100644 --- a/src/differentiation/compute_jacobian_ad.jl +++ b/src/differentiation/compute_jacobian_ad.jl @@ -348,8 +348,9 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number}, if FiniteDiff._use_findstructralnz(sparsity) rows_index, cols_index = ArrayInterface.findstructralnz(sparsity) else - rows_index = nothing - cols_index = nothing + cartind = vec(CartesianIndices(x)) + rows_index = Base.Iterators.map(first ∘ Tuple, cartind) + cols_index = Base.Iterators.map(last ∘ Tuple, cartind) end # fast path if J and sparsity are both AbstractSparseMatrix and have the same sparsity pattern