|
1 | 1 | module LinearSolveSparseArraysExt |
2 | 2 |
|
3 | | -using LinearSolve, LinearAlgebra |
4 | | -using SparseArrays |
5 | | -using SparseArrays: AbstractSparseMatrixCSC, nonzeros, rowvals, getcolptr |
6 | | -using LinearSolve: BLASELTYPES, pattern_changed, ArrayInterface |
| 3 | +using LinearSolve: LinearSolve, BLASELTYPES, pattern_changed, ArrayInterface, |
| 4 | + @get_cacheval, CHOLMODFactorization, GenericFactorization, GenericLUFactorization, |
| 5 | + KLUFactorization, LUFactorization, NormalCholeskyFactorization, OperatorAssumptions, |
| 6 | + QRFactorization, RFLUFactorization, UMFPACKFactorization, solve |
| 7 | +using ArrayInterface: ArrayInterface |
| 8 | +using LinearAlgebra: LinearAlgebra, I, Hermitian, Symmetric, cholesky, ldiv!, lu, lu!, QR |
| 9 | +using SparseArrays: SparseArrays, AbstractSparseArray, AbstractSparseMatrixCSC, SparseMatrixCSC, |
| 10 | + nonzeros, rowvals, getcolptr, sparse, sprand |
| 11 | +using SparseArrays.UMFPACK: UMFPACK_OK |
| 12 | +using Base: /, \, convert |
| 13 | +using SciMLBase: SciMLBase, LinearProblem, ReturnCode |
| 14 | +import StaticArraysCore: SVector |
7 | 15 |
|
8 | 16 | # Can't `using KLU` because cannot have a dependency in there without |
9 | 17 | # requiring the user does `using KLU` |
@@ -187,7 +195,7 @@ function SciMLBase.solve!( |
187 | 195 | end |
188 | 196 |
|
189 | 197 | F = LinearSolve.@get_cacheval(cache, :UMFPACKFactorization) |
190 | | - if F.status == SparseArrays.UMFPACK.UMFPACK_OK |
| 198 | + if F.status == UMFPACK_OK |
191 | 199 | y = ldiv!(cache.u, F, cache.b) |
192 | 200 | SciMLBase.build_linear_solution(alg, y, nothing, cache; retcode = ReturnCode.Success) |
193 | 201 | else |
@@ -298,36 +306,36 @@ function LinearSolve.init_cacheval(alg::NormalCholeskyFactorization, |
298 | 306 | Symmetric{T, <:AbstractSparseArray{T}}}, b, u, Pl, Pr, |
299 | 307 | maxiters::Int, abstol, reltol, verbose::Bool, |
300 | 308 | assumptions::OperatorAssumptions) where {T <: BLASELTYPES} |
301 | | - LinearSolve.ArrayInterface.cholesky_instance(convert(AbstractMatrix, A)) |
| 309 | + ArrayInterface.cholesky_instance(convert(AbstractMatrix, A)) |
302 | 310 | end |
303 | 311 |
|
304 | 312 | # Specialize QR for the non-square case |
305 | 313 | # Missing ldiv! definitions: https://github.com/JuliaSparse/SparseArrays.jl/issues/242 |
306 | 314 | function LinearSolve._ldiv!(x::Vector, |
307 | | - A::Union{SparseArrays.QR, LinearAlgebra.QRCompactWY, |
| 315 | + A::Union{QR, LinearAlgebra.QRCompactWY, |
308 | 316 | SparseArrays.SPQR.QRSparse, |
309 | 317 | SparseArrays.CHOLMOD.Factor}, b::Vector) |
310 | 318 | x .= A \ b |
311 | 319 | end |
312 | 320 |
|
313 | 321 | function LinearSolve._ldiv!(x::AbstractVector, |
314 | | - A::Union{SparseArrays.QR, LinearAlgebra.QRCompactWY, |
| 322 | + A::Union{QR, LinearAlgebra.QRCompactWY, |
315 | 323 | SparseArrays.SPQR.QRSparse, |
316 | 324 | SparseArrays.CHOLMOD.Factor}, b::AbstractVector) |
317 | 325 | x .= A \ b |
318 | 326 | end |
319 | 327 |
|
320 | 328 | # Ambiguity removal |
321 | | -function LinearSolve._ldiv!(::LinearSolve.SVector, |
| 329 | +function LinearSolve._ldiv!(::SVector, |
322 | 330 | A::Union{SparseArrays.CHOLMOD.Factor, LinearAlgebra.QR, |
323 | 331 | LinearAlgebra.QRCompactWY, SparseArrays.SPQR.QRSparse}, |
324 | 332 | b::AbstractVector) |
325 | 333 | (A \ b) |
326 | 334 | end |
327 | | -function LinearSolve._ldiv!(::LinearSolve.SVector, |
| 335 | +function LinearSolve._ldiv!(::SVector, |
328 | 336 | A::Union{SparseArrays.CHOLMOD.Factor, LinearAlgebra.QR, |
329 | 337 | LinearAlgebra.QRCompactWY, SparseArrays.SPQR.QRSparse}, |
330 | | - b::LinearSolve.SVector) |
| 338 | + b::SVector) |
331 | 339 | (A \ b) |
332 | 340 | end |
333 | 341 |
|
|
363 | 371 | function LinearSolve.init_cacheval(alg::QRFactorization, A::SparseMatrixCSC{Float64, <:Integer}, b, u, Pl, Pr, |
364 | 372 | maxiters::Int, abstol, reltol, verbose::Bool, |
365 | 373 | assumptions::OperatorAssumptions) |
366 | | - LinearSolve.ArrayInterface.qr_instance(convert(AbstractMatrix, A), alg.pivot) |
| 374 | + ArrayInterface.qr_instance(convert(AbstractMatrix, A), alg.pivot) |
367 | 375 | end |
368 | 376 |
|
369 | 377 | function LinearSolve.init_cacheval( |
|
0 commit comments