Skip to content

Commit e110ae2

Browse files
Merge pull request #104 from SciML/fill_bang
Only fill the nonzeros
2 parents 2b68207 + 83e0d84 commit e110ae2

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/factorization.jl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,22 @@ end
237237
# Try to never use it.
238238
function init_cacheval(alg::Union{QRFactorization,SVDFactorization,GenericFactorization}, A, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
239239
newA = copy(convert(AbstractMatrix,A))
240-
fill!(newA,true)
240+
if newA isa SparseMatrixCSC
241+
fill!(nonzeros(newA),true)
242+
else
243+
fill!(newA,true)
244+
end
241245
do_factorization(alg, newA, b, u)
242246
end
243247

244248
# Ambiguity handling dispatch
245249
function init_cacheval(alg::Union{QRFactorization,SVDFactorization}, A::StridedMatrix{<:LinearAlgebra.BlasFloat}, b, u, Pl, Pr, maxiters, abstol, reltol, verbose)
246250
newA = copy(convert(AbstractMatrix,A))
247-
fill!(newA,true)
251+
if newA isa SparseMatrixCSC
252+
fill!(nonzeros(newA),true)
253+
else
254+
fill!(newA,true)
255+
end
248256
do_factorization(alg, newA, b, u)
249257
end
250258

0 commit comments

Comments
 (0)