Skip to content

Commit a4ce8de

Browse files
committed
Default to QR with BandedMatrix{BigFloat}
1 parent c9d6b06 commit a4ce8de

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

ext/LinearSolveBandedMatricesExt.jl

+8-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ function defaultalg(A::BandedMatrix, b, oa::OperatorAssumptions{Bool})
1616
end
1717
end
1818

19+
function defaultalg(
20+
A::BandedMatrix{T}, b, oa::OperatorAssumptions{Bool}) where {T <: BigFloat}
21+
return DefaultLinearSolver(DefaultAlgorithmChoice.QRFactorization)
22+
end
23+
1924
function defaultalg(A::Symmetric{<:Number, <:BandedMatrix}, b, ::OperatorAssumptions{Bool})
2025
return DefaultLinearSolver(DefaultAlgorithmChoice.CholeskyFactorization)
2126
end
@@ -42,8 +47,9 @@ for alg in (:SVDFactorization, :MKLLUFactorization, :DiagonalFactorization,
4247
end
4348
end
4449

45-
function init_cacheval(::LUFactorization, A::BandedMatrix, b, u, Pl, Pr, maxiters::Int,
46-
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions)
50+
function init_cacheval(::LUFactorization, A::BandedMatrix{T}, b, u, Pl, Pr, maxiters::Int,
51+
abstol, reltol, verbose::Bool, assumptions::OperatorAssumptions) where {T}
52+
(T <: BigFloat) && return qr(similar(A, 0, 0))
4753
return lu(similar(A, 0, 0))
4854
end
4955

test/adjoint.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ db12 = ForwardDiff.gradient(x -> f(eltype(x).(A), x), copy(b1))
4545
@test db1 db12
4646

4747
# Test complex numbers
48-
A = rand(n, n) + 1im*rand(n, n);
49-
b1 = rand(n) + 1im*rand(n);
48+
A = rand(n, n) + 1im * rand(n, n);
49+
b1 = rand(n) + 1im * rand(n);
5050

5151
function f3(A, b1, b2; alg = KrylovJL_GMRES())
5252
prob = LinearProblem(A, b1)

test/banded.jl

+6
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,9 @@ A = AlmostBandedMatrix(BandedMatrix(fill(2.0, n + 2, n), (1, 1)), fill(3.0, 2, n
5252
A[band(0)] .+= 1:n
5353

5454
@test_nowarn solve(LinearProblem(A, b))
55+
56+
# Workaround for no lu from BandedMatrices
57+
A = BandedMatrix{BigFloat}(ones(3, 3), (0, 0))
58+
b = BigFloat[1, 2, 3]
59+
prob = LinearProblem(A, b)
60+
@test_nowarn solve(prob)

test/defaults_loading.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ prob = LinearProblem(mat, rhs)
3131

3232
using Sparspak
3333
sol = solve(prob).u
34-
@test sol isa Vector{BigFloat}
34+
@test sol isa Vector{BigFloat}

0 commit comments

Comments
 (0)