-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
64 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
module LinearSolveBandedMatricesExt | ||
|
||
using BandedMatrices, LinearAlgebra, LinearSolve | ||
import LinearSolve: defaultalg, | ||
do_factorization, init_cacheval, DefaultLinearSolver, DefaultAlgorithmChoice | ||
|
||
# Defaults for BandedMatrices | ||
function defaultalg(A::BandedMatrix, b, ::OperatorAssumptions) | ||
return DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization) | ||
end | ||
|
||
function defaultalg(A::Symmetric{<:Number, <:BandedMatrix}, b, ::OperatorAssumptions) | ||
return DefaultLinearSolver(DefaultAlgorithmChoice.CholeskyFactorization) | ||
end | ||
|
||
# BandedMatrices `qr` doesn't allow other args without causing an ambiguity | ||
do_factorization(alg::QRFactorization, A::BandedMatrix, b, u) = alg.inplace ? qr!(A) : qr(A) | ||
|
||
function do_factorization(alg::LUFactorization, A::BandedMatrix, b, u) | ||
_pivot = alg.pivot isa NoPivot ? Val(false) : Val(true) | ||
return lu!(A, _pivot; check = false) | ||
end | ||
|
||
# For BandedMatrix | ||
for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization, | ||
:SparspakFactorization, :KLUFactorization, :UMFPACKFactorization, | ||
:GenericLUFactorization, :RFLUFactorization, :BunchKaufmanFactorization, | ||
:CHOLMODFactorization, :NormalCholeskyFactorization, :LDLtFactorization, | ||
:AppleAccelerateLUFactorization, :CholeskyFactorization) | ||
@eval begin | ||
function init_cacheval(::$(alg), ::BandedMatrix, b, u, Pl, Pr, maxiters::Int, | ||
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) | ||
return nothing | ||
end | ||
end | ||
end | ||
|
||
function init_cacheval(::LUFactorization, A::BandedMatrix, b, u, Pl, Pr, maxiters::Int, | ||
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) | ||
return lu(similar(A, 0, 0)) | ||
end | ||
|
||
# For Symmetric BandedMatrix | ||
for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization, | ||
:SparspakFactorization, :KLUFactorization, :UMFPACKFactorization, | ||
:GenericLUFactorization, :RFLUFactorization, :BunchKaufmanFactorization, | ||
:CHOLMODFactorization, :NormalCholeskyFactorization, | ||
:AppleAccelerateLUFactorization, :QRFactorization, :LUFactorization) | ||
@eval begin | ||
function init_cacheval(::$(alg), ::Symmetric{<:Number, <:BandedMatrix}, b, u, Pl, | ||
Pr, maxiters::Int, abstol, reltol, verbose::Bool, | ||
assumptions::OperatorAssumptions) | ||
return nothing | ||
end | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters