Skip to content

Commit d0b8dd2

Browse files
committed
Support Symmetric(::BandedBlockBandedMatrix)
1 parent 074293b commit d0b8dd2

File tree

4 files changed

+31
-2
lines changed

4 files changed

+31
-2
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.11.4"
3+
version = "0.11.5"
44

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

src/AbstractBlockBandedMatrix.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,21 @@ conjlayout(::Type{T}, ::BandedBlockBandedRows{Lay}) where {T<:Complex,Lay} = Ban
3939
conjlayout(::Type{T}, ::BlockBandedColumns{Lay}) where {T<:Complex,Lay} = BlockBandedColumns{typeof(conjlayout(T,Lay))}()
4040
conjlayout(::Type{T}, ::BlockBandedRows{Lay}) where {T<:Complex,Lay} = BlockBandedRows{typeof(conjlayout(T,Lay))}()
4141

42+
symmetriclayout(::AbstractBandedBlockBandedLayout) = BandedBlockBandedLayout()
43+
hermitianlayout(::AbstractBandedBlockBandedLayout) = BandedBlockBandedLayout()
44+
45+
function blockbandwidths(S::HermOrSym)
46+
l, u = blockbandwidths(parent(S))
47+
if S.uplo == 'U'
48+
(u, u)
49+
else
50+
(l, l)
51+
end
52+
end
53+
function subblockbandwidths(S::HermOrSym)
54+
m = max(subblockbandwidths(parent(S))...)
55+
(m,m)
56+
end
4257

4358
# AbstractBandedMatrix must implement
4459

src/BlockBandedMatrices.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import ArrayLayouts: BlasMatLmulVec, MatLmulVec, MatLmulMat,
2727
AbstractColumnMajor, DenseColumnMajor, ColumnMajor,
2828
DiagonalLayout, MulAdd, mul, colsupport, rowsupport,
2929
_qr, _factorize, _copyto!, zero!, layout_replace_in_print_matrix,
30-
transposelayout, conjlayout
30+
transposelayout, conjlayout, symmetriclayout, hermitianlayout
3131

3232
import BlockArrays: blocksize, blockcheckbounds, BlockedUnitRange, blockisequal, DefaultBlockAxis,
3333
Block, BlockSlice, unblock, block, blockindex,

test/test_bandedblockbanded.jl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,20 @@ import ArrayLayouts: RangeCumsum
516516
@test convert(AbstractArray{Float64}, A) == convert(AbstractMatrix{Float64}, A) == A
517517
@test convert(AbstractArray{Int}, A) convert(AbstractMatrix{Int}, A) A
518518
end
519+
520+
@testset "Symmetric" begin
521+
l, u = 2, 1
522+
λ, μ = 2, 1
523+
N = M = 4
524+
cols = rows = 1:N
525+
data = reshape(collect(1:+μ+1)*(l+u+1)*sum(cols)), ((λ + μ + 1) * (l + u + 1), sum(cols)))
526+
A = _BandedBlockBandedMatrix(data, rows, cols, (l, u), (λ, μ))
527+
528+
@test BandedBlockBandedMatrix(Symmetric(A)) == Symmetric(Matrix(A))
529+
@test BandedBlockBandedMatrix(Symmetric(A,:L)) == Symmetric(Matrix(A),:L)
530+
@test BandedBlockBandedMatrix(Hermitian(A)) == Hermitian(Matrix(A))
531+
@test BandedBlockBandedMatrix(Hermitian(A,:L)) == Hermitian(Matrix(A),:L)
532+
end
519533
end
520534

521535
if false # turned off since tests have check-bounds=yes

0 commit comments

Comments
 (0)