Skip to content

Commit b14390e

Browse files
authored
Fix multiplication with empty HessenbergQ (#1326)
1 parent 9d139f5 commit b14390e

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/lapack.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6135,10 +6135,11 @@ for (ormhr, elty) in
61356135
chkside(side)
61366136
chktrans(trans)
61376137
n = checksquare(A)
6138+
ntau = length(tau)
61386139
mC, nC = size(C, 1), size(C, 2)
61396140

6140-
if n - length(tau) != 1
6141-
throw(DimensionMismatch(lazy"tau has length $(length(tau)), needs $(n - 1)"))
6141+
if max(n - 1, 0) != ntau
6142+
throw(DimensionMismatch(lazy"tau has length $ntau, needs $(n - 1)"))
61426143
end
61436144
if (side == 'L' && mC != n) || (side == 'R' && nC != n)
61446145
throw(DimensionMismatch("A and C matrices are not conformable"))

test/hessenberg.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,4 +286,11 @@ end
286286
end
287287
end
288288

289+
@testset "multiplication with empty HessenbergQ" begin
290+
@test ones(2, 0)*hessenberg(zeros(0,0)).Q == zeros(2,0)
291+
@test_throws DimensionMismatch ones(2, 1)*hessenberg(zeros(0,0)).Q
292+
@test hessenberg(zeros(0,0)).Q * ones(0, 2) == zeros(0,2)
293+
@test_throws DimensionMismatch hessenberg(zeros(0,0)).Q * ones(1, 2)
294+
end
295+
289296
end # module TestHessenberg

0 commit comments

Comments
 (0)