Skip to content

Commit db88dd1

Browse files
authored
Fix Schur Factorization for 0x0 matrices (#23360)
Fixes #23359
1 parent 2c915ab commit db88dd1

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

base/linalg/lapack.jl

+16-16
Original file line numberDiff line numberDiff line change
@@ -5558,15 +5558,15 @@ for (gees, gges, elty) in
55585558
# $ WR( * )
55595559
function gees!(jobvs::Char, A::StridedMatrix{$elty})
55605560
chkstride1(A)
5561-
n = checksquare(A)
5562-
sdim = Vector{BlasInt}(1)
5563-
wr = similar(A, $elty, n)
5564-
wi = similar(A, $elty, n)
5565-
ldvs = jobvs == 'V' ? n : 1
5566-
vs = similar(A, $elty, ldvs, n)
5567-
work = Vector{$elty}(1)
5561+
n = checksquare(A)
5562+
sdim = Vector{BlasInt}(1)
5563+
wr = similar(A, $elty, n)
5564+
wi = similar(A, $elty, n)
5565+
vs = similar(A, $elty, jobvs == 'V' ? n : 0, n)
5566+
ldvs = max(size(vs, 1), 1)
5567+
work = Vector{$elty}(1)
55685568
lwork = BlasInt(-1)
5569-
info = Ref{BlasInt}()
5569+
info = Ref{BlasInt}()
55705570
for i = 1:2 # first call returns lwork as work[1]
55715571
ccall((@blasfunc($gees), liblapack), Void,
55725572
(Ptr{UInt8}, Ptr{UInt8}, Ptr{Void}, Ptr{BlasInt},
@@ -5651,16 +5651,16 @@ for (gees, gges, elty, relty) in
56515651
# COMPLEX*16 A( LDA, * ), VS( LDVS, * ), W( * ), WORK( * )
56525652
function gees!(jobvs::Char, A::StridedMatrix{$elty})
56535653
chkstride1(A)
5654-
n = checksquare(A)
5655-
sort = 'N'
5656-
sdim = BlasInt(0)
5657-
w = similar(A, $elty, n)
5658-
ldvs = jobvs == 'V' ? n : 1
5659-
vs = similar(A, $elty, ldvs, n)
5660-
work = Vector{$elty}(1)
5654+
n = checksquare(A)
5655+
sort = 'N'
5656+
sdim = BlasInt(0)
5657+
w = similar(A, $elty, n)
5658+
vs = similar(A, $elty, jobvs == 'V' ? n : 1, n)
5659+
ldvs = max(size(vs, 1), 1)
5660+
work = Vector{$elty}(1)
56615661
lwork = BlasInt(-1)
56625662
rwork = Vector{$relty}(n)
5663-
info = Ref{BlasInt}()
5663+
info = Ref{BlasInt}()
56645664
for i = 1:2 # first call returns lwork as work[1]
56655665
ccall((@blasfunc($gees), liblapack), Void,
56665666
(Ptr{UInt8}, Ptr{UInt8}, Ptr{Void}, Ptr{BlasInt},

test/linalg/schur.jl

+6
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,10 @@ aimg = randn(n,n)/2
109109
@test NS[:Z] sZ
110110
end
111111
end
112+
@testset "0x0 matrix" for A in (zeros(eltya, 0, 0), view(rand(eltya, 2, 2), 1:0, 1:0))
113+
T, Z, λ = Base.LinAlg.schur(A)
114+
@test T == A
115+
@test Z == A
116+
@test λ == zeros(0)
117+
end
112118
end

0 commit comments

Comments
 (0)