From 75a180f0dc97669f444168362adbeb1546c745a6 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 24 Jun 2026 09:54:11 +0100 Subject: [PATCH 1/2] Support blockbandwidths fore blocked BandedMatrix --- Project.toml | 2 +- src/interfaceimpl.jl | 7 +++++++ test/test_misc.jl | 4 +++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index f3efdf3..cc18e35 100644 --- a/Project.toml +++ b/Project.toml @@ -1,6 +1,6 @@ name = "BlockBandedMatrices" uuid = "ffab5731-97b5-5995-9138-79e8c1846df0" -version = "0.13.4" +version = "0.13.5" [deps] ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a" diff --git a/src/interfaceimpl.jl b/src/interfaceimpl.jl index 8e5885f..b47650a 100644 --- a/src/interfaceimpl.jl +++ b/src/interfaceimpl.jl @@ -57,6 +57,13 @@ function blockbandwidths(::AbstractBandedLayout, (a,b)::Tuple{AbstractBlockedUni end end +function blockbandwidths(::AbstractBandedLayout, (a,b)::Tuple{BlockedOneTo{<:Any,<:AbstractRange}, BlockedOneTo{<:Any,<:AbstractRange}}, A) + a ≠ b && return blockbandwidths(UnknownLayout(), (a,b), A) # can implement same step but not done yet + l,u = bandwidths(A) + s = step(a.lasts) # normal blocksize + (l+s-1) ÷ s, (u+s-1) ÷ s +end + diff --git a/test/test_misc.jl b/test/test_misc.jl index fc6d29d..79bd22c 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -193,7 +193,9 @@ Base.size(F::FiniteDifference) = (F.n,F.n) @test blockcolsupport(B,Block(1)) == Block.(1:3) @test blockcolsupport(B,Block(3)) == Block.(2:4) @test blockrowsupport(B,Block(1)) == Block.(1:2) - @test blockrowsupport(B,Block(4)) == Block.(3:5) + @test blockrowsupport(B,Block(4)) == Block.(2:4) + + @test blockbandwidths(B) == (2,1) Q = Eye((a,))[:,Block(2)] @test Q isa BandedMatrix From e8517e62997c48265fd30c77ff4c07b88f689e7f Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Wed, 24 Jun 2026 10:56:16 +0100 Subject: [PATCH 2/2] Update test_misc.jl --- test/test_misc.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/test_misc.jl b/test/test_misc.jl index 79bd22c..d670aad 100644 --- a/test/test_misc.jl +++ b/test/test_misc.jl @@ -193,9 +193,8 @@ Base.size(F::FiniteDifference) = (F.n,F.n) @test blockcolsupport(B,Block(1)) == Block.(1:3) @test blockcolsupport(B,Block(3)) == Block.(2:4) @test blockrowsupport(B,Block(1)) == Block.(1:2) - @test blockrowsupport(B,Block(4)) == Block.(2:4) + @test blockrowsupport(B,Block(4)) == Block.(3:5) - @test blockbandwidths(B) == (2,1) Q = Eye((a,))[:,Block(2)] @test Q isa BandedMatrix @@ -212,6 +211,9 @@ Base.size(F::FiniteDifference) = (F.n,F.n) B = _BandedMatrix(randn(5,length(a)), a, 3, 1) @test blockbandwidths(B) == (4,0) + + B = _BandedMatrix(BlockedArray(randn(5,length(a)),(Base.OneTo(5),a)), a, 3, 1) + @test blockbandwidths(B) == (2,1) end end