diff --git a/Project.toml b/Project.toml index 9ecf5e4..4dd1bc4 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "BlockDiagonals" uuid = "0a1fb500-61f7-11e9-3c65-f5ef3456f9f0" authors = ["Invenia Technical Computing Corporation"] -version = "0.1.35" +version = "0.1.36" [deps] ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4" diff --git a/src/base_maths.jl b/src/base_maths.jl index a42e356..d74ccf1 100644 --- a/src/base_maths.jl +++ b/src/base_maths.jl @@ -66,6 +66,8 @@ end ## Subtraction Base.:-(B::BlockDiagonal) = BlockDiagonal(.-(blocks(B))) Base.:-(M::AbstractMatrix, B::BlockDiagonal) = M + -B +Base.:-(B::BlockDiagonal, M::AbstractMatrix) = -M + B +Base.:-(B::BlockDiagonal, B2::BlockDiagonal) = B + (-B2) ## Multiplication Base.:*(n::Number, B::BlockDiagonal) = B * n diff --git a/test/base_maths.jl b/test/base_maths.jl index 9b775e7..4ee295d 100644 --- a/test/base_maths.jl +++ b/test/base_maths.jl @@ -76,6 +76,8 @@ using Test @test -b1 == -Matrix(b1) @test b1 - b1 == Matrix(b1) - Matrix(b1) + @test Matrix(b1) - b2 == Matrix(b1) - Matrix(b2) + @test b1 - Matrix(b2) == Matrix(b1) - Matrix(b2) end @testset "Multiplication" begin