@@ -1040,4 +1040,35 @@ end
10401040 @test_throws DimensionMismatch D1 * S * D1
10411041end
10421042
1043+ @testset " multiplication of sparse and dense matrices" begin
1044+ function test_mul (A, B)
1045+ expected = Matrix (A) * Matrix (B)
1046+ @test A * B ≈ expected
1047+ C = similar (expected)
1048+ @test mul! (C, A, B) === C
1049+ @test C ≈ expected
1050+ ElType = eltype (C)
1051+ vs = Any[false , true , zero (ElType), one (ElType), one (ElType) + one (ElType)]
1052+ for α in vs
1053+ for β in vs
1054+ C .= rand .(ElType)
1055+ expected′ = expected .* α .+ C .* β
1056+ @test mul! (C, A, B, α, β) === C
1057+ @test C ≈ expected′
1058+ end
1059+ end
1060+ end
1061+
1062+ for ElType in [Int, Float64, ComplexF64, BigFloat]
1063+ SP = sprand (ElType, 10 , 10 , 0.3 )
1064+ D = rand (ElType, 10 , 10 )
1065+ for f1 in [identity, adjoint, transpose]
1066+ for f2 in [identity, adjoint, transpose]
1067+ test_mul (f1 (SP), f2 (D))
1068+ test_mul (f1 (D), f2 (SP))
1069+ end
1070+ end
1071+ end
1072+ end
1073+
10431074end
0 commit comments