Skip to content

Commit a9547ed

Browse files
Merge pull request #179 from JuliaDiff/fill_bang
don't fill! on a SparseMatrix
2 parents de19848 + fe1402b commit a9547ed

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/differentiation/compute_jacobian_ad.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,11 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
296296
color_i = 1
297297
maxcolor = maximum(colorvec)
298298

299-
fill!(J, zero(eltype(J)))
299+
if J isa SparseMatrixCSC
300+
fill!(nonzeros(J), zero(eltype(J)))
301+
else
302+
fill!(J, zero(eltype(J)))
303+
end
300304

301305
if FiniteDiff._use_findstructralnz(sparsity)
302306
rows_index, cols_index = ArrayInterface.findstructralnz(sparsity)

0 commit comments

Comments
 (0)