diff --git a/test/runtests.jl b/test/runtests.jl index 40b921b..43d6217 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -76,6 +76,12 @@ end @test D' * M ≈ D' * Mf @test M * E' ≈ Mf * E' @test E * M' ≈ E * Mf' + @test size(Mf, 1) == 15 + @test size(Mf, 2) == 10 + @test size(Mf, 3) == 1 + @test length(Mf) == 150 + @test similar(Mf, (3, 4)) isa Matrix{eltype(U)} + @test similar(Mf, Int, (3, 4)) isa Matrix{Int} @test !any(isnan, Mf) @test !any(isinf, Mf) V1, U1 = [1; 1;;], [1 -1] @@ -203,6 +209,21 @@ end check_fmfm_fm_alloc(Mf, Mf_A, ws3x3, Cf15x8) end + # mul! FM×FM→FM: elseif branch (k-rank output) and DimensionMismatch + let + Ua = myrand(T, 15, 2); Va = myrand(T, 2, 10) + Ub = myrand(T, 10, 3); Vb = myrand(T, 3, 8) + Af = FactoredMatrix(Ua, Va); Bf = FactoredMatrix(Ub, Vb) + expected = (Ua * Va) * (Ub * Vb) + # k-rank output (C rank = k = 2) + Ck = FactoredMatrix(Matrix{T}(undef, 15, 2), Matrix{T}(undef, 2, 8)) + mul!(Ck, Af, Bf) + @test Array(Ck) ≈ expected + # wrong rank → DimensionMismatch + Cbad = FactoredMatrix(Matrix{T}(undef, 15, 4), Matrix{T}(undef, 4, 8)) + @test_throws DimensionMismatch("C's factorization size doesn't match the result of A*B") mul!(Cbad, Af, Bf) + end + # mul! vector (with and without cache) let b = vec(myrand(T, 10, 1))