Skip to content

Commit

Permalink
Fix bunch kaufman type stability (JuliaLang#26375)
Browse files Browse the repository at this point in the history
* Fix type instability in return type of sytrf functions

* Add test for 0x0 case
  • Loading branch information
haampie authored and andreasnoack committed Mar 9, 2018
1 parent a475e93 commit 4181aad
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions stdlib/LinearAlgebra/src/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3896,7 +3896,7 @@ for (syconv, sysv, sytrf, sytri, sytrs, elty) in
chkuplo(uplo)
ipiv = similar(A, BlasInt, n)
if n == 0
return A, ipiv
return A, ipiv, zero(BlasInt)
end
work = Vector{$elty}(uninitialized, 1)
lwork = BlasInt(-1)
Expand Down Expand Up @@ -4046,7 +4046,7 @@ for (sysv, sytrf, sytri, sytrs, syconvf, elty) in
chkuplo(uplo)
ipiv = similar(A, BlasInt, n)
if n == 0
return A, ipiv
return A, ipiv, zero(BlasInt)
end
work = Vector{$elty}(uninitialized, 1)
lwork = BlasInt(-1)
Expand Down Expand Up @@ -4496,7 +4496,7 @@ for (sysv, sytrf, sytri, sytrs, elty, relty) in
chkuplo(uplo)
ipiv = similar(A, BlasInt, n)
if n == 0
return A, ipiv
return A, ipiv, zero(BlasInt)
end
work = Vector{$elty}(uninitialized, 1)
lwork = BlasInt(-1)
Expand Down Expand Up @@ -4647,7 +4647,7 @@ for (sysv, sytrf, sytri, sytrs, syconvf, elty, relty) in
chkuplo(uplo)
ipiv = similar(A, BlasInt, n)
if n == 0
return A, ipiv
return A, ipiv, zero(BlasInt)
end
work = Vector{$elty}(uninitialized, 1)
lwork = BlasInt(-1)
Expand Down
1 change: 1 addition & 0 deletions stdlib/LinearAlgebra/test/bunchkaufman.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,6 @@ end

@test_throws DomainError logdet(bkfact([-1 -1; -1 1]))
@test logabsdet(bkfact([8 4; 4 2]))[1] == -Inf
@test isa(bkfact(Symmetric(ones(0,0))), BunchKaufman) # 0x0 matrix

end # module TestBunchKaufman
4 changes: 2 additions & 2 deletions stdlib/LinearAlgebra/test/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ end
B,ipiv = LAPACK.sytrf!('U',B)
@test triu(inv(A)) triu(LAPACK.sytri!('U',B,ipiv)) rtol=eps(cond(A))
@test_throws DimensionMismatch LAPACK.sytrs!('U',B,ipiv,rand(elty,11,5))
@test LAPACK.sytrf!('U',zeros(elty,0,0)) == (zeros(elty,0,0),zeros(BlasInt,0))
@test LAPACK.sytrf!('U',zeros(elty,0,0)) == (zeros(elty,0,0),zeros(BlasInt,0),zero(BlasInt))
end

# Rook-pivoting variants
Expand All @@ -372,7 +372,7 @@ end
B,ipiv = LAPACK.sytrf_rook!('U', B)
@test triu(inv(A)) triu(LAPACK.sytri_rook!('U', B, ipiv)) rtol=eps(cond(A))
@test_throws DimensionMismatch LAPACK.sytrs_rook!('U', B, ipiv, rand(elty, 11, 5))
@test LAPACK.sytrf_rook!('U',zeros(elty, 0, 0)) == (zeros(elty, 0, 0),zeros(BlasInt, 0))
@test LAPACK.sytrf_rook!('U',zeros(elty, 0, 0)) == (zeros(elty, 0, 0),zeros(BlasInt, 0),zero(BlasInt))
A = rand(elty, 10, 10)
A = A + transpose(A) #symmetric!
b = rand(elty, 10)
Expand Down

0 comments on commit 4181aad

Please sign in to comment.