Skip to content

Commit c2ad519

Browse files
dbruegElOceanografo
authored andcommitted
LinearAlgebra._generic_matmul! : Avoid division by zero for tile_size. (JuliaLang#39790)
1 parent 8717e6a commit c2ad519

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

stdlib/LinearAlgebra/src/matmul.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat
823823

824824
tile_size = 0
825825
if isbitstype(R) && isbitstype(T) && isbitstype(S) && (tA == 'N' || tB != 'N')
826-
tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T))))
826+
tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T), 1)))
827827
end
828828
@inbounds begin
829829
if tile_size > 0

stdlib/LinearAlgebra/test/matmul.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,16 @@ end
720720
@test D C
721721
end
722722

723+
@testset "size zero types in matrix mult (see issue 39362)" begin
724+
A = [missing missing; missing missing]
725+
v = [missing, missing]
726+
@test (A * v == v) === missing
727+
M = fill(1.0, 2, 2)
728+
a = fill(missing, 2, 1)
729+
@test (a' * M * a == fill(missing,1,1)) === missing
730+
end
731+
732+
723733
@testset "multiplication of empty matrices without calling zero" begin
724734
r, c = rand(0:9, 2)
725735
A = collect(Number, rand(r, c))

0 commit comments

Comments
 (0)