Skip to content

Commit c438420

Browse files
abstractsparsematrix
1 parent b302756 commit c438420

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/differentiation/compute_jacobian_ad.jl

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

299-
if J isa SparseMatrixCSC
299+
if J isa AbstractSparseMatrix
300300
fill!(nonzeros(J), zero(eltype(J)))
301301
else
302302
fill!(J, zero(eltype(J)))
@@ -309,7 +309,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
309309
cols_index = 1:size(J,2)
310310
end
311311

312-
# fast path if J and sparsity are both SparseMatrixCSC and have the same sparsity pattern
312+
# fast path if J and sparsity are both AbstractSparseMatrix and have the same sparsity pattern
313313
sparseCSC_common_sparsity = FiniteDiff._use_sparseCSC_common_sparsity(J, sparsity)
314314

315315
vecx = vec(x)
@@ -356,7 +356,7 @@ function forwarddiff_color_jacobian!(J::AbstractMatrix{<:Number},
356356
J[rows_index, cols_index] .+= (colorvec[cols_index] .== color_i) .* dx[rows_index]
357357
+= means requires a zero'd out start
358358
=#
359-
if J isa SparseMatrixCSC
359+
if J isa AbstractSparseMatrix
360360
@. setindex!((J.nzval,),getindex((J.nzval,),rows_index) + (getindex((colorvec,),cols_index) == color_i) * getindex((vecdx,),rows_index),rows_index)
361361
else
362362
@. setindex!((J,),getindex((J,),rows_index, cols_index) + (getindex((colorvec,),cols_index) == color_i) * getindex((vecdx,),rows_index),rows_index, cols_index)

0 commit comments

Comments
 (0)