Skip to content

Commit

Permalink
Fix Schur Factorization for 0x0 matrices (#23360)
Browse files Browse the repository at this point in the history
Fixes #23359
  • Loading branch information
andreasnoack authored Aug 21, 2017
1 parent 2c915ab commit db88dd1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 16 deletions.
32 changes: 16 additions & 16 deletions base/linalg/lapack.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5558,15 +5558,15 @@ for (gees, gges, elty) in
# $ WR( * )
function gees!(jobvs::Char, A::StridedMatrix{$elty})
chkstride1(A)
n = checksquare(A)
sdim = Vector{BlasInt}(1)
wr = similar(A, $elty, n)
wi = similar(A, $elty, n)
ldvs = jobvs == 'V' ? n : 1
vs = similar(A, $elty, ldvs, n)
work = Vector{$elty}(1)
n = checksquare(A)
sdim = Vector{BlasInt}(1)
wr = similar(A, $elty, n)
wi = similar(A, $elty, n)
vs = similar(A, $elty, jobvs == 'V' ? n : 0, n)
ldvs = max(size(vs, 1), 1)
work = Vector{$elty}(1)
lwork = BlasInt(-1)
info = Ref{BlasInt}()
info = Ref{BlasInt}()
for i = 1:2 # first call returns lwork as work[1]
ccall((@blasfunc($gees), liblapack), Void,
(Ptr{UInt8}, Ptr{UInt8}, Ptr{Void}, Ptr{BlasInt},
Expand Down Expand Up @@ -5651,16 +5651,16 @@ for (gees, gges, elty, relty) in
# COMPLEX*16 A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * )
function gees!(jobvs::Char, A::StridedMatrix{$elty})
chkstride1(A)
n = checksquare(A)
sort = 'N'
sdim = BlasInt(0)
w = similar(A, $elty, n)
ldvs = jobvs == 'V' ? n : 1
vs = similar(A, $elty, ldvs, n)
work = Vector{$elty}(1)
n = checksquare(A)
sort = 'N'
sdim = BlasInt(0)
w = similar(A, $elty, n)
vs = similar(A, $elty, jobvs == 'V' ? n : 1, n)
ldvs = max(size(vs, 1), 1)
work = Vector{$elty}(1)
lwork = BlasInt(-1)
rwork = Vector{$relty}(n)
info = Ref{BlasInt}()
info = Ref{BlasInt}()
for i = 1:2 # first call returns lwork as work[1]
ccall((@blasfunc($gees), liblapack), Void,
(Ptr{UInt8}, Ptr{UInt8}, Ptr{Void}, Ptr{BlasInt},
Expand Down
6 changes: 6 additions & 0 deletions test/linalg/schur.jl
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,10 @@ aimg = randn(n,n)/2
@test NS[:Z] sZ
end
end
@testset "0x0 matrix" for A in (zeros(eltya, 0, 0), view(rand(eltya, 2, 2), 1:0, 1:0))
T, Z, λ = Base.LinAlg.schur(A)
@test T == A
@test Z == A
@test λ == zeros(0)
end
end

0 comments on commit db88dd1

Please sign in to comment.