|
| 1 | +module LinearSolveFastAlmostBandedMatricesExt |
| 2 | + |
| 3 | +using FastAlmostBandedMatrices, LinearAlgebra, LinearSolve |
| 4 | +import LinearSolve: defaultalg, |
| 5 | + do_factorization, init_cacheval, DefaultLinearSolver, DefaultAlgorithmChoice |
| 6 | + |
| 7 | +function defaultalg(A::AlmostBandedMatrix, b, oa::OperatorAssumptions) |
| 8 | + if oa.issq |
| 9 | + return DefaultLinearSolver(DefaultAlgorithmChoice.DirectLdiv!) |
| 10 | + else |
| 11 | + return DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization) |
| 12 | + end |
| 13 | +end |
| 14 | + |
| 15 | +# For BandedMatrix |
| 16 | +for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization, |
| 17 | + :SparspakFactorization, :KLUFactorization, :UMFPACKFactorization, |
| 18 | + :GenericLUFactorization, :RFLUFactorization, :BunchKaufmanFactorization, |
| 19 | + :CHOLMODFactorization, :NormalCholeskyFactorization, :LDLtFactorization, |
| 20 | + :AppleAccelerateLUFactorization, :CholeskyFactorization, :LUFactorization) |
| 21 | + @eval begin |
| 22 | + function init_cacheval(::$(alg), ::AlmostBandedMatrix, b, u, Pl, Pr, maxiters::Int, |
| 23 | + abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) |
| 24 | + return nothing |
| 25 | + end |
| 26 | + end |
| 27 | +end |
| 28 | + |
| 29 | +function do_factorization(alg::QRFactorization, A::AlmostBandedMatrix, b, u) |
| 30 | + return alg.inplace ? qr!(A) : qr(A) |
| 31 | +end |
| 32 | + |
| 33 | +end |
0 commit comments