@@ -19,6 +19,8 @@ using Test
1919 b64 = BlockDiagonal ([rand (rng, 2 , 2 ), rand (rng, 2 , 2 )])
2020 b32 = BlockDiagonal ([rand (rng, Float32, 2 , 2 ), rand (rng, Float32, 2 , 2 )])
2121
22+ bns = BlockDiagonal ([rand (rng, N1, N2), rand (rng, N2, N3), rand (rng, N3, N1)])
23+
2224 @testset " Addition" begin
2325 @testset " BlockDiagonal + BlockDiagonal" begin
2426 @test b1 + b1 isa BlockDiagonal
@@ -58,6 +60,15 @@ using Test
5860 @test D + b1 isa BlockDiagonal
5961 @test D + b1 == D + Matrix (b1)
6062 @test_throws DimensionMismatch D′ + b1
63+
64+ # Non-square blocks
65+ @test D + bns isa Matrix
66+ @test D + bns == D + Matrix (bns)
67+ @test_throws DimensionMismatch D′ + bns
68+
69+ @test bns + D isa Matrix
70+ @test bns + D == D + Matrix (bns)
71+ @test_throws DimensionMismatch bns + D′
6172 end
6273
6374 @testset " BlockDiagonal + UniformScaling" begin
@@ -69,11 +80,11 @@ using Test
6980 @test 5 I + b1 == 5 I + Matrix (b1)
7081 end
7182 end # Addition
72-
83+
7384 @testset " Subtraction" begin
7485 @test - b1 isa BlockDiagonal
7586 @test b1 - b1 isa BlockDiagonal
76-
87+
7788 @test - b1 == - Matrix (b1)
7889 @test b1 - b1 == Matrix (b1) - Matrix (b1)
7990 @test Matrix (b1) - b2 == Matrix (b1) - Matrix (b2)
0 commit comments