Skip to content

Commit

Permalink
Special case blockbandwidths for unitblocks (#207)
Browse files Browse the repository at this point in the history
* Special case for unitblocks

* Update test_misc.jl
  • Loading branch information
dlfivefifty authored May 20, 2024
1 parent 95fb340 commit dd5623f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "BlockBandedMatrices"
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
version = "0.13"
version = "0.13.1"

[deps]
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"
Expand Down
8 changes: 8 additions & 0 deletions src/interfaceimpl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,11 @@ _blockkron(::Tuple{Vararg{AbstractBandedLayout}}, A) = BandedBlockBandedMatrix(B


sublayout(::DiagonalLayout{L}, inds::Type{<:NTuple{2,BS}}) where {L,BS<:BlockSlice{<:BlockRange1}} = bandedblockbandedcolumns(sublayout(L(),Tuple{BS}))



##
# special for unitblocks
blockbandwidths(A::BlockedMatrix{<:Any,<:Any,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = bandwidths(A.blocks)
blockbandwidths(A::BlockedMatrix{<:Any,<:Diagonal,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = bandwidths(A.blocks)
subblockbandwidths(A::BlockedMatrix{<:Any,<:Any,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = (0,0)
9 changes: 9 additions & 0 deletions test/test_misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,15 @@ Base.size(F::FiniteDifference) = (F.n,F.n)

@test BandedBlockBandedMatrix(D̃_yy) D_yy
end

@testset "banded with unitblocks" begin
A = BlockedArray(brand(5,4,1,2), Ones{Int}(5), Ones{Int}(4))
@test bandwidths(A) == blockbandwidths(A) == (1,2)
@test subblockbandwidths(A) == (0,0)
D = BlockedArray(Diagonal(1:5), Ones{Int}(5), Ones{Int}(5))
@test bandwidths(D) == blockbandwidths(D) == (0,0)
@test subblockbandwidths(D) == (0,0)
end
end

end # module

2 comments on commit dd5623f

@dlfivefifty
Copy link
Member 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/107215

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

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.13.1 -m "<description of version>" dd5623f25f2fade10d2d1304b31e883938501c82
git push origin v0.13.1

Please sign in to comment.