-
-
Notifications
You must be signed in to change notification settings - Fork 55
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
44 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,38 @@ | ||
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 | ||
|
||
# Only init for `qr`, `ldlt` and `cholesky` | ||
for alg in (:SVDFactorization, :LUFactorization, :MKLLUFactorization, | ||
:DiagonalFactorization, :SparspakFactorization, :KLUFactorization, | ||
:UMFPACKFactorization, :GenericLUFactorization, :RFLUFactorization, | ||
:BunchKaufmanFactorization, :CHOLMODFactorization, :NormalCholeskyFactorization, | ||
:AppleAccelerateLUFactorization) | ||
@eval begin | ||
function init_cacheval(::$(alg), ::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