Skip to content

Commit 08d6dd4

Browse files
committed
This reverts commit f7b2f37, reversing changes made to 4137e6b.
1 parent f7b2f37 commit 08d6dd4

File tree

7 files changed

+29
-79
lines changed

7 files changed

+29
-79
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
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.8.2"
3+
version = "0.8.1"
44

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

src/AbstractBlockBandedMatrix.jl

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,14 @@
1+
####
2+
# Matrix memory layout traits
3+
#
4+
# if MemoryLayout(A) returns BandedColumnMajor, you must override
5+
# pointer and leadingdimension
6+
# in addition to the banded matrix interface
7+
####
18

2-
"""
3-
AbstractBlockBandedLayout
4-
5-
isa a `MemoryLayout` that indicates that the array implements the block-banded
6-
interface.
7-
"""
89
abstract type AbstractBlockBandedLayout <: AbstractBlockLayout end
9-
10-
"""
11-
AbstractBandedBlockBandedLayout
12-
13-
isa a `MemoryLayout` that indicates that the array implements the banded-block-banded
14-
interface.
15-
"""
1610
abstract type AbstractBandedBlockBandedLayout <: AbstractBlockBandedLayout end
1711

18-
19-
struct BandedBlockBandedLayout <: AbstractBandedBlockBandedLayout end
20-
struct BlockBandedLayout <: AbstractBlockBandedLayout end
21-
2212
struct BandedBlockBandedColumns{LAY} <: AbstractBandedBlockBandedLayout end
2313
struct BandedBlockBandedRows{LAY} <: AbstractBandedBlockBandedLayout end
2414
struct BlockBandedColumns{LAY} <: AbstractBlockBandedLayout end

src/BandedBlockBandedMatrix.jl

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -318,18 +318,13 @@ end
318318
end
319319

320320
## structured matrix methods ##
321-
function _bandedblockbanded_replace_in_print_matrix(A, i, j, s)
321+
function Base.replace_in_print_matrix(A::BandedBlockBandedMatrix, i::Integer, j::Integer, s::AbstractString)
322322
bi = findblockindex.(axes(A), (i,j))
323323
I,J = block.(bi)
324324
i,j = blockindex.(bi)
325-
l,u = blockbandwidths(A)
326-
λ,μ = subblockbandwidths(A)
327-
-l Int(J-I)  u && -λ j-i μ ? s : Base.replace_with_centered_mark(s)
325+
-A.l Int(J-I)  A.u && -A.λ j-i A.μ ? s : Base.replace_with_centered_mark(s)
328326
end
329327

330-
Base.replace_in_print_matrix(A::BandedBlockBandedMatrix, i::Integer, j::Integer, s::AbstractString) =
331-
_bandedblockbanded_replace_in_print_matrix(A, i, j, s)
332-
333328

334329
############
335330
# Indexing #
@@ -418,43 +413,32 @@ sublayout(::BandedBlockBandedColumnMajor, ::Type{<:Tuple{BlockSlice{Block1},Bloc
418413
sublayout(::BandedBlockBandedColumnMajor, ::Type{<:Tuple{BlockSlice{BlockRange1},BlockSlice{Block1}}}) = BandedBlockBandedColumnMajor()
419414
sublayout(::BandedBlockBandedColumnMajor, ::Type{<:Tuple{BlockSlice{BlockRange1},BlockSlice{BlockIndexRange1}}}) = BandedBlockBandedColumnMajor()
420415

421-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{Block1},BlockSlice{Block1}}}) = BandedLayout()
422-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{BlockIndexRange1},BlockSlice{BlockIndexRange1}}}) = BandedLayout()
423-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{BlockIndexRange1},BlockSlice{Block1}}}) = BandedLayout()
424-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{Block1},BlockSlice{BlockIndexRange1}}}) = BandedLayout()
425-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{BlockRange1},BlockSlice{BlockRange1}}}) = BandedBlockBandedLayout()
426-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{Block1},BlockSlice{BlockRange1}}}) = BandedBlockBandedLayout()
427-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{BlockRange1},BlockSlice{Block1}}}) = BandedBlockBandedLayout()
428-
sublayout(::AbstractBandedBlockBandedLayout, ::Type{<:Tuple{BlockSlice{BlockRange1},BlockSlice{BlockIndexRange1}}}) = BandedBlockBandedLayout()
429-
430-
431-
sub_materialize(::AbstractBandedBlockBandedLayout, V, _) = BandedBlockBandedMatrix(V)
432-
433416
isbanded(A::SubArray{<:Any,2,<:BandedBlockBandedMatrix}) = MemoryLayout(typeof(A)) == BandedColumnMajor()
434417
isbandedblockbanded(A::SubArray{<:Any,2,<:BandedBlockBandedMatrix}) = MemoryLayout(typeof(A)) == BandedBlockBandedColumnMajor()
435418

436419

437-
subblockbandwidths(V::SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1},<:BlockSlice{BlockRange1}}}) =
438-
subblockbandwidths(parent(V))
420+
subblockbandwidths(V::SubBandedBlockBandedMatrix) = subblockbandwidths(parent(V))
439421

440-
function blockbandwidths(V::SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1},<:BlockSlice{Block1}}})
422+
function blockbandwidths(V::SubBandedBlockBandedMatrix{<:Any,BlockRange1,Block1})
441423
A = parent(V)
424+
442425
KR = parentindices(V)[1].block.indices[1]
443426
J = parentindices(V)[2].block
444427
shift = Int(KR[1])-Int(J)
445428
blockbandwidth(A,1) - shift, blockbandwidth(A,2) + shift
446429
end
447430

448-
function blockbandwidths(V::SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{<:Block1},<:BlockSlice{<:BlockRange1}}})
431+
function blockbandwidths(V::SubBandedBlockBandedMatrix{<:Any,Block1,BlockRange1})
449432
A = parent(V)
433+
450434
K = parentindices(V)[1].block
451435
JR = parentindices(V)[2].block.indices[1]
452436
shift = Int(K)-Int(JR[1])
453-
l,u = blockbandwidths(A)
454-
l - shift, u + shift
437+
438+
blockbandwidth(A,1) - shift, blockbandwidth(A,2) + shift
455439
end
456440

457-
function blockbandwidths(V::SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{<:BlockRange1},<:BlockSlice{<:BlockRange1}}})
441+
function blockbandwidths(V::SubBandedBlockBandedMatrix{<:Any,BlockRange1,BlockRange1})
458442
A = parent(V)
459443

460444
KR = parentindices(V)[1].block.indices[1]

src/BlockBandedMatrices.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import SparseArrays: sparse
2323

2424
import ArrayLayouts: BlasMatLmulVec,
2525
triangularlayout, UpperTriangularLayout, TriangularLayout, MatLdivVec,
26-
triangulardata, sublayout, sub_materialize,
26+
triangulardata, sublayout,
2727
AbstractColumnMajor, DenseColumnMajor, ColumnMajor,
2828
DiagonalLayout, MulAdd, mul, colsupport, rowsupport,
2929
_qr, _factorize, _copyto!
@@ -38,7 +38,7 @@ import BandedMatrices: isbanded, bandwidths, bandwidth, banded_getindex, colrang
3838
inbands_setindex!, inbands_getindex, banded_setindex!,
3939
banded_generic_axpy!,
4040
BlasFloat, banded_dense_axpy!, MemoryLayout,
41-
BandedLayout, BandedColumnMajor,
41+
BandedColumnMajor,
4242
BandedSubBandedMatrix, bandeddata, tribandeddata,
4343
_BandedMatrix, colstart, colstop, rowstart, rowstop,
4444
BandedStyle, _fill_lmul!, bandshift,
@@ -50,7 +50,7 @@ export BandedBlockBandedMatrix, BlockBandedMatrix, BlockSkylineMatrix, blockband
5050

5151
const Block1 = Block{1,Int}
5252
const BlockRange1 = BlockRange{1,Tuple{UnitRange{Int}}}
53-
const BlockIndexRange1 = BlockIndexRange{1,Tuple{UnitRange{Int}}}
53+
const BlockIndexRange1 = BlockIndexRange{1,Tuple{UnitRange{Int}}}
5454

5555
blockcolrange(A...) = blockcolsupport(A...)
5656
blockrowrange(A...) = blockrowsupport(A...)

src/linalg.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,6 @@ sublayout(::BlockBandedColumnMajor, ::Type{<:Tuple{<:BlockSlice{BlockRange1}, <:
9393
sublayout(::BlockBandedColumnMajor, ::Type{<:Tuple{<:BlockSlice{BlockRange1}, <:BlockSlice{BlockIndexRange1}}}) = ColumnMajor()
9494
sublayout(::BlockBandedColumnMajor, ::Type{<:Tuple{<:BlockSlice{BlockIndexRange1}, <:BlockSlice{BlockIndexRange1}}}) = ColumnMajor()
9595

96-
isblockbanded(V::SubArray{<:Any,2,<:Any,<:Tuple{<:BlockSlice{BlockRange1}, <:BlockSlice{BlockRange1}}}) =
97-
isblockbanded(parent(V))
98-
99-
sub_materialize(::AbstractBlockBandedLayout, V, _) = BlockBandedMatrix(V)
10096

10197
strides(V::SubBlockSkylineMatrix{<:Any,LL,UU,<:Union{BlockRange1,Block1},Block1}) where {LL,UU} =
10298
(1,parent(V).block_sizes.block_strides[Int(parentindices(V)[2].block)])
@@ -138,3 +134,5 @@ strides(V::SubBlockSkylineMatrix{T,LL,UU,BlockIndexRange1,BlockIndexRange1}) whe
138134
(1,parent(V).block_sizes.block_strides[Int(parentindices(V)[2].block.block)])
139135

140136
MemoryLayout(V::SubBlockSkylineMatrix{T,LL,UU,BlockIndexRange1,BlockIndexRange1}) where {T,LL,UU} = ColumnMajor()
137+
138+

test/test_bandedblockbanded.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,7 @@ import BlockBandedMatrices: _BandedBlockBandedMatrix, blockcolsupport, blockrows
298298
@test B isa BandedBlockBandedMatrix
299299
@test blockbandwidths(V) == blockbandwidths(B) == (2,0)
300300
@test subblockbandwidths(V) == subblockbandwidths(B) == subblockbandwidths(A) == (λ,μ)
301-
@test B == V == A[Block.(2:3), Block.(3:4)]
302-
303-
@test A[Block.(2:3), Block.(3:4)] isa BandedBlockBandedMatrix
301+
@test B == V
304302

305303
x = randn(size(B,2))
306304
y = similar(x, size(B,1))

test/test_blockbanded.jl

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Base.Broadcast: materialize!
1111
cols = rows = 1:N
1212

1313
@test Matrix(BlockBandedMatrix(Zeros(sum(rows),sum(cols)), rows, cols, (l,u))) ==
14-
Array(BlockBandedMatrix(Zeros(sum(rows),sum(cols)), rows, cols, (l,u))) ==
14+
Array(BlockBandedMatrix(Zeros(sum(rows),sum(cols)), rows, cols, (l,u))) ==
1515
zeros(Float64, 10, 10)
1616

1717
@test Matrix(BlockBandedMatrix{Int}(Zeros(sum(rows),sum(cols)), rows,cols, (l,u))) ==
@@ -35,11 +35,13 @@ import Base.Broadcast: materialize!
3535
N = M = 4
3636
cols = rows = 1:N
3737
A = BlockBandedMatrix{Int}(undef, rows,cols, (l,u))
38-
A.data .= 1:length(A.data)
38+
A.data .= 1:length(A.data)
3939

4040
@test A[1,1] == 1
4141
@test A[1,3] == 10
4242

43+
44+
4345
@test blockbandwidth(A,1) == 1
4446
@test blockbandwidths(A) == (l,u)
4547

@@ -90,34 +92,12 @@ import Base.Broadcast: materialize!
9092
@test ret[1,2] == 0
9193
end
9294

93-
@testset "block-banded matrix interface for blockranges" begin
94-
l , u = 1,1
95-
N = M = 4
96-
cols = rows = 1:N
97-
A = BlockBandedMatrix{Int}(undef, rows,cols, (l,u))
98-
A.data .= 1:length(A.data)
99-
100-
V = view(A, Block.(2:3), Block.(3:4))
101-
@test isblockbanded(V)
102-
103-
B = BlockBandedMatrix(V)
104-
@test B isa BlockBandedMatrix
105-
@test blockbandwidths(V) == blockbandwidths(B) == (2,0)
106-
@test B == V == A[Block.(2:3), Block.(3:4)]
107-
108-
@test A[Block.(2:3), Block.(3:4)] isa BlockBandedMatrix
109-
110-
x = randn(size(B,2))
111-
y = similar(x, size(B,1))
112-
@test all((similar(y) .= MulAdd(B, x)) .=== (similar(y) .= MulAdd(V,x)))
113-
end
114-
11595
@testset "BlockBandedMatrix indexing" begin
11696
l , u = 1,1
11797
N = M = 10
11898
cols = rows = 1:N
11999
A = BlockBandedMatrix{Float64}(undef, rows,cols, (l,u))
120-
A.data .= 1:length(A.data)
100+
A.data .= 1:length(A.data)
121101

122102
A[1,1] = 5
123103
@test A[1,1] == 5

0 commit comments

Comments
 (0)