Skip to content

Commit

Permalink
Bugfix for zero matrix in A_ldiv_B! for QRPivoted (JuliaLang#22831)
Browse files Browse the repository at this point in the history
* Bugfix for zero matrix in A_ldiv_B! for QRPivoted.

* Address review comments.
  • Loading branch information
GunnarFarneback authored and andreasnoack committed Jul 17, 2017
1 parent 5535ecb commit bf47fd9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 6 additions & 2 deletions base/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,9 +704,13 @@ function A_ldiv_B!(A::QRPivoted{T}, B::StridedMatrix{T}, rcond::Real) where T<:B
mA, nA = size(A.factors)
nr = min(mA,nA)
nrhs = size(B, 2)
if nr == 0 return zeros(T, 0, nrhs), 0 end
if nr == 0
return zeros(T, 0, nrhs), 0
end
ar = abs(A.factors[1])
if ar == 0 return zeros(T, nr, nrhs), 0 end
if ar == 0
return zeros(T, nA, nrhs), 0
end
rnk = 1
xmin = ones(T, 1)
xmax = ones(T, 1)
Expand Down
8 changes: 8 additions & 0 deletions test/linalg/qr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,11 @@ B = rand(7,2)

# Issue 16520
@test_throws DimensionMismatch ones(3,2)\(1:5)

# Issue 22810
let
A = zeros(1, 2)
B = zeros(1, 1)
@test A \ B == zeros(2, 1)
@test qrfact(A, Val(true)) \ B == zeros(2, 1)
end

0 comments on commit bf47fd9

Please sign in to comment.