Skip to content

Commit c176f88

Browse files
Fix non-square sparse views
Fixes #287
1 parent c83bf11 commit c176f88

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/factorization.jl

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

9+
function _ldiv!(x::AbstractVector, A::SparseArrays.SPQR.QRSparse, b::AbstractVector)
10+
x .= A \ b
11+
end
12+
913
function SciMLBase.solve(cache::LinearCache, alg::AbstractFactorization; kwargs...)
1014
if cache.isfresh
1115
fact = do_factorization(alg, cache.A, cache.b, cache.u)

test/nonsquare.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,9 @@ b = rand(n)
2424
prob = LinearProblem(A, b)
2525
res = Matrix(A) \ b
2626
@test solve(prob, KrylovJL_CRAIGMR()) res
27+
28+
A = sprandn(1000, 100, 0.1)
29+
b = randn(1001)
30+
prob = LinearProblem(A, view(b, 1:1000))
31+
linsolve = init(prob, QRFactorization())
32+
solve(linsolve)

0 commit comments

Comments
 (0)