Skip to content

Commit a42114d

Browse files
fix QR non-square handling
1 parent a9f0730 commit a42114d

File tree

4 files changed

+14
-1
lines changed

4 files changed

+14
-1
lines changed

src/LinearSolve.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ export LinearSolveFunction
5858
export KrylovJL, KrylovJL_CG, KrylovJL_GMRES, KrylovJL_BICGSTAB, KrylovJL_MINRES,
5959
IterativeSolversJL, IterativeSolversJL_CG, IterativeSolversJL_GMRES,
6060
IterativeSolversJL_BICGSTAB, IterativeSolversJL_MINRES,
61-
KrylovKitJL, KrylovKitJL_CG, KrylovKitJL_GMRES
61+
KrylovKitJL, KrylovKitJL_CG, KrylovKitJL_GMRES, KrylovJL_LSMR
6262

6363
end

src/factorization.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ function _ldiv!(x::Vector, A::Factorization, b::Vector)
55
ldiv!(A, x)
66
end
77

8+
# Specialize QR for the non-square case
9+
function _ldiv!(x::Vector, A::QRFactorization, b::Vector)
10+
ldiv!(x, A, b)
11+
end
12+
813
function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization; kwargs...)
914
if cache.isfresh
1015
fact = do_factorization(alg, cache.A, cache.b, cache.u)

test/nonsquare.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using LinearSolve
2+
using SparseArrays, LinearAlgebra
3+
4+
m, n = 13, 3
5+
A = sprand(m, n, 0.5); b = rand(m);
6+
prob = LinearProblem(A, b)
7+
solve(prob)

test/runtests.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ end
2121
if GROUP == "All" || GROUP == "Core"
2222
@time @safetestset "Basic Tests" begin include("basictests.jl") end
2323
@time @safetestset "Zero Initialization Tests" begin include("zeroinittests.jl") end
24+
@time @safetestset "Non-Square Tests" begin include("nonsquare.jl") end
2425
end
2526

2627
if GROUP == "LinearSolveCUDA"

0 commit comments

Comments
 (0)