Skip to content

Commit

Permalink
Merge pull request #113 from invenia/mz/subtraction
Browse files Browse the repository at this point in the history
implement faster subtraction
  • Loading branch information
mzgubic authored Jul 28, 2022
2 parents 6223d3f + e754c0f commit 932b020
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 2 additions & 0 deletions src/base_maths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions test/base_maths.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

2 comments on commit 932b020

@mzgubic
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/65159

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.36 -m "<description of version>" 932b02001417eab1d42e8293279971ac1ea03d2c
git push origin v0.1.36

Please sign in to comment.