Skip to content

Commit

Permalink
LinearAlgebra._generic_matmul! : Avoid division by zero for tile_size. (
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrueg authored Feb 26, 2021
1 parent b39d697 commit eca3e86
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion stdlib/LinearAlgebra/src/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ function _generic_matmatmul!(C::AbstractVecOrMat{R}, tA, tB, A::AbstractVecOrMat

tile_size = 0
if isbitstype(R) && isbitstype(T) && isbitstype(S) && (tA == 'N' || tB != 'N')
tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T))))
tile_size = floor(Int, sqrt(tilebufsize / max(sizeof(R), sizeof(S), sizeof(T), 1)))
end
@inbounds begin
if tile_size > 0
Expand Down
10 changes: 10 additions & 0 deletions stdlib/LinearAlgebra/test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,16 @@ end
@test D C
end

@testset "size zero types in matrix mult (see issue 39362)" begin
A = [missing missing; missing missing]
v = [missing, missing]
@test (A * v == v) === missing
M = fill(1.0, 2, 2)
a = fill(missing, 2, 1)
@test (a' * M * a == fill(missing,1,1)) === missing
end


@testset "multiplication of empty matrices without calling zero" begin
r, c = rand(0:9, 2)
A = collect(Number, rand(r, c))
Expand Down

0 comments on commit eca3e86

Please sign in to comment.