Skip to content

Commit 14c6ad3

Browse files
dkarraschjishnub
authored andcommitted
Fix multiplication with empty HessenbergQ (#1326)
(cherry picked from commit b14390e)
1 parent fdfa1a8 commit 14c6ad3

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
@@ -6130,10 +6130,11 @@ for (ormhr, elty) in
61306130
chkside(side)
61316131
chktrans(trans)
61326132
n = checksquare(A)
6133+
ntau = length(tau)
61336134
mC, nC = size(C, 1), size(C, 2)
61346135

6135-
if n - length(tau) != 1
6136-
throw(DimensionMismatch(lazy"tau has length $(length(tau)), needs $(n - 1)"))
6136+
if max(n - 1, 0) != ntau
6137+
throw(DimensionMismatch(lazy"tau has length $ntau, needs $(n - 1)"))
61376138
end
61386139
if (side == 'L' && mC != n) || (side == 'R' && nC != n)
61396140
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)