Skip to content

Commit dd5623f

Browse files
authored
Special case blockbandwidths for unitblocks (#207)
* Special case for unitblocks * Update test_misc.jl
1 parent 95fb340 commit dd5623f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Project.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "BlockBandedMatrices"
22
uuid = "ffab5731-97b5-5995-9138-79e8c1846df0"
3-
version = "0.13"
3+
version = "0.13.1"
44

55
[deps]
66
ArrayLayouts = "4c555306-a7a7-4459-81d9-ec55ddd5c99a"

src/interfaceimpl.jl

+8
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ _blockkron(::Tuple{Vararg{AbstractBandedLayout}}, A) = BandedBlockBandedMatrix(B
7373

7474

7575
sublayout(::DiagonalLayout{L}, inds::Type{<:NTuple{2,BS}}) where {L,BS<:BlockSlice{<:BlockRange1}} = bandedblockbandedcolumns(sublayout(L(),Tuple{BS}))
76+
77+
78+
79+
##
80+
# special for unitblocks
81+
blockbandwidths(A::BlockedMatrix{<:Any,<:Any,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = bandwidths(A.blocks)
82+
blockbandwidths(A::BlockedMatrix{<:Any,<:Diagonal,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = bandwidths(A.blocks)
83+
subblockbandwidths(A::BlockedMatrix{<:Any,<:Any,<:NTuple{2,BlockedOneTo{Int,<:AbstractUnitRange{Int}}}}) = (0,0)

test/test_misc.jl

+9
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,15 @@ Base.size(F::FiniteDifference) = (F.n,F.n)
247247

248248
@test BandedBlockBandedMatrix(D̃_yy) D_yy
249249
end
250+
251+
@testset "banded with unitblocks" begin
252+
A = BlockedArray(brand(5,4,1,2), Ones{Int}(5), Ones{Int}(4))
253+
@test bandwidths(A) == blockbandwidths(A) == (1,2)
254+
@test subblockbandwidths(A) == (0,0)
255+
D = BlockedArray(Diagonal(1:5), Ones{Int}(5), Ones{Int}(5))
256+
@test bandwidths(D) == blockbandwidths(D) == (0,0)
257+
@test subblockbandwidths(D) == (0,0)
258+
end
250259
end
251260

252261
end # module

0 commit comments

Comments
 (0)