Skip to content

Commit d5a3afb

Browse files
Merge pull request #262 from chriselrod/rflu
Use `eltype(b)` if `A === nothing`
2 parents fa64510 + bf6b60e commit d5a3afb

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

src/default.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ function defaultalg(A, b, ::OperatorAssumptions{true})
131131
if length(b) <= 10
132132
alg = GenericLUFactorization()
133133
elseif (length(b) <= 100 || (isopenblas() && length(b) <= 500)) &&
134-
eltype(A) <: Union{Float32, Float64}
134+
(A === nothing ? eltype(b) <: Union{Float32, Float64} :
135+
eltype(A) <: Union{Float32, Float64})
135136
alg = RFLUFactorization()
136137
#elseif A === nothing || A isa Matrix
137138
# alg = FastLUFactorization()

test/default_algs.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using LinearSolve, LinearAlgebra, SparseArrays, Test
2+
@test LinearSolve.defaultalg(nothing, zeros(3)) isa GenericLUFactorization
3+
@test LinearSolve.defaultalg(nothing, zeros(50)) isa RFLUFactorization
4+
@test LinearSolve.defaultalg(nothing, zeros(600)) isa LUFactorization
5+
@test LinearSolve.defaultalg(LinearAlgebra.Diagonal(zeros(5)), zeros(5)) isa
6+
DiagonalFactorization
7+
8+
@test LinearSolve.defaultalg(nothing, zeros(5),
9+
LinearSolve.OperatorAssumptions{false}()) isa QRFactorization
10+
11+
@test LinearSolve.defaultalg(sprand(1000, 1000, 0.01), zeros(1000)) isa KLUFactorization
12+
@test LinearSolve.defaultalg(sprand(11000, 11000, 0.001), zeros(11000)) isa
13+
UMFPACKFactorization

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if GROUP == "All" || GROUP == "Core"
2525
@time @safetestset "Zero Initialization Tests" begin include("zeroinittests.jl") end
2626
@time @safetestset "Non-Square Tests" begin include("nonsquare.jl") end
2727
@time @safetestset "SparseVector b Tests" begin include("sparse_vector.jl") end
28+
@time @safetestset "Default Alg Tests" begin include("default_algs.jl") end
2829
end
2930

3031
if GROUP == "LinearSolveCUDA"

0 commit comments

Comments
 (0)