Skip to content

Fix lmul!/rmul! for 0-sized matrices #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix lmul!/rmul! for 0-sized matrices
  • Loading branch information
jishnub committed Apr 14, 2025
commit 48169a81011fbfef2a97c3df90a9b7b446d264db
2 changes: 2 additions & 0 deletions src/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ function lmul!(D::Diagonal, B::Bidiagonal)
matmul_size_check(size(D), size(B))
(; dv, ev) = B
isL = B.uplo == 'L'
iszero(size(D,1)) && return B
dv[1] = D.diag[1] * dv[1]
for i in axes(ev,1)
ev[i] = D.diag[i + isL] * ev[i]
Expand Down Expand Up @@ -575,6 +576,7 @@ function rmul!(B::Bidiagonal, D::Diagonal)
matmul_size_check(size(B), size(D))
(; dv, ev) = B
isU = B.uplo == 'U'
iszero(size(D,1)) && return B
dv[1] *= D.diag[1]
for i in axes(ev,1)
ev[i] *= D.diag[i + isU]
Expand Down
9 changes: 9 additions & 0 deletions test/bidiag.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1192,4 +1192,13 @@ end
@test_throws msg ldiv!(C, B, zeros(2,1))
end

@testset "l/rmul with 0-sized matrices" begin
n = 0
B = Bidiagonal(ones(n), ones(max(n-1,0)), :U)
B2 = copy(B)
D = Diagonal(ones(n))
@test lmul!(D, B) == B2
@test rmul!(B, D) == B2
end

end # module TestBidiagonal