Skip to content

Commit

Permalink
Test with different eltypes and Symmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
jishnub committed Dec 23, 2024
1 parent 0c4cd0a commit 92c9e4a
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions test/matmul.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1149,18 +1149,22 @@ end
end

@testset "issue #1147: error messages in matmul" begin
@test_throws "incompatible dimensions for matrix multiplication" zeros(0,0) * zeros(1,5)
@test_throws "incompatible dimensions for matrix multiplication" zeros(0,0) * zeros(1)
@test_throws "incompatible dimensions for matrix multiplication" zeros(0) * zeros(2,5)
@test_throws "incompatible dimensions for matrix multiplication" mul!(zeros(0,0), zeros(5), zeros(5))
@test_throws "incompatible dimensions for matrix multiplication" mul!(zeros(0,0), zeros(1,5), zeros(0,0))
@test_throws "incompatible destination size" mul!(zeros(0,2), zeros(1,5), zeros(5,2))
@test_throws "incompatible destination size" mul!(zeros(1,0), zeros(1,5), zeros(5,2))
@test_throws "incompatible destination size" mul!(zeros(0,0), zeros(1,5), zeros(5))
@test_throws "incompatible destination size" mul!(zeros(0), zeros(1,5), zeros(5))

@test_throws "expected size: (2, 2)" LinearAlgebra.matmul2x2!(zeros(2,2), 'N', 'N', zeros(2,3), zeros(3,2))
@test_throws "expected size: (2, 2)" LinearAlgebra.matmul2x2!(zeros(2,3), 'N', 'N', zeros(2,2), zeros(2,3))
for T in (Int, Float64, ComplexF64)
for f in (identity, Symmetric)
@test_throws "incompatible dimensions for matrix multiplication" f(zeros(T,0,0)) * zeros(T,1,5)
@test_throws "incompatible dimensions for matrix multiplication" f(zeros(T,0,0)) * zeros(T,1)
@test_throws "incompatible dimensions for matrix multiplication" zeros(T,0) * f(zeros(T,2,2))
@test_throws "incompatible dimensions for matrix multiplication" mul!(zeros(T,0,0), zeros(T,5), zeros(T,5))
@test_throws "incompatible dimensions for matrix multiplication" mul!(zeros(T,0,0), f(zeros(T,1,1)), zeros(T,0,0))
@test_throws "incompatible destination size" mul!(zeros(T,0,2), f(zeros(T,1,1)), zeros(T,1,2))
@test_throws "incompatible destination size" mul!(zeros(T,1,0), f(zeros(T,1,1)), zeros(T,1,2))
@test_throws "incompatible destination size" mul!(zeros(T,0,0), f(zeros(T,1,1)), zeros(T,1))
@test_throws "incompatible destination size" mul!(zeros(T,0), f(zeros(T,1,1)), zeros(T,1))
end

@test_throws "expected size: (2, 2)" LinearAlgebra.matmul2x2!(zeros(T,2,2), 'N', 'N', zeros(T,2,3), zeros(T,3,2))
@test_throws "expected size: (2, 2)" LinearAlgebra.matmul2x2!(zeros(T,2,3), 'N', 'N', zeros(T,2,2), zeros(T,2,3))
end
end

end # module TestMatmul

0 comments on commit 92c9e4a

Please sign in to comment.