|
933 | 933 | @test B[1,2] == B[Int8(1),UInt16(2)] == B[big(1), Int16(2)] |
934 | 934 | end |
935 | 935 |
|
| 936 | +@testset "rmul!/lmul! with banded matrices" begin |
| 937 | + dv, ev = rand(4), rand(3) |
| 938 | + for A in (Bidiagonal(dv, ev, :U), Bidiagonal(dv, ev, :L)) |
| 939 | + @testset "$(nameof(typeof(B)))" for B in ( |
| 940 | + Bidiagonal(dv, ev, :U), |
| 941 | + Bidiagonal(dv, ev, :L), |
| 942 | + Diagonal(dv) |
| 943 | + ) |
| 944 | + @test_throws ArgumentError rmul!(B, A) |
| 945 | + @test_throws ArgumentError lmul!(A, B) |
| 946 | + end |
| 947 | + D = Diagonal(dv) |
| 948 | + @test rmul!(copy(A), D) ≈ A * D |
| 949 | + @test lmul!(D, copy(A)) ≈ D * A |
| 950 | + end |
| 951 | + @testset "non-commutative" begin |
| 952 | + S32 = SizedArrays.SizedArray{(3,2)}(rand(3,2)) |
| 953 | + S33 = SizedArrays.SizedArray{(3,3)}(rand(3,3)) |
| 954 | + S22 = SizedArrays.SizedArray{(2,2)}(rand(2,2)) |
| 955 | + for uplo in (:L, :U) |
| 956 | + B = Bidiagonal(fill(S32, 4), fill(S32, 3), uplo) |
| 957 | + D = Diagonal(fill(S22, size(B,2))) |
| 958 | + @test rmul!(copy(B), D) ≈ B * D |
| 959 | + D = Diagonal(fill(S33, size(B,1))) |
| 960 | + @test lmul!(D, copy(B)) ≈ D * B |
| 961 | + end |
| 962 | + |
| 963 | + B = Bidiagonal(fill(S33, 4), fill(S33, 3), :U) |
| 964 | + D = Diagonal(fill(S32, 4)) |
| 965 | + @test lmul!(B, Array(D)) ≈ B * D |
| 966 | + B = Bidiagonal(fill(S22, 4), fill(S22, 3), :U) |
| 967 | + @test rmul!(Array(D), B) ≈ D * B |
| 968 | + end |
| 969 | +end |
| 970 | + |
936 | 971 | @testset "conversion to Tridiagonal for immutable bands" begin |
937 | 972 | n = 4 |
938 | 973 | dv = FillArrays.Fill(3, n) |
|
0 commit comments