From 92c9e4a4ac9298630e96cb6384cd45dafbdd3acd Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Mon, 23 Dec 2024 16:40:25 +0530 Subject: [PATCH] Test with different eltypes and Symmetric --- test/matmul.jl | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/test/matmul.jl b/test/matmul.jl index 5e60992..805edea 100644 --- a/test/matmul.jl +++ b/test/matmul.jl @@ -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