From 82f65b1182e35abb5d4ef35080cb21ff54a83aff Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Thu, 6 Feb 2025 09:46:10 +0000 Subject: [PATCH] Fix Adjoint/Transpose * BlockBanded --- Project.toml | 2 +- src/linalg.jl | 4 ++-- test/test_adjtransblockbanded.jl | 12 ++++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/Project.toml b/Project.toml index fbc68ec..9c5efd9 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/linalg.jl b/src/linalg.jl index b018ae2..941f292 100644 --- a/src/linalg.jl +++ b/src/linalg.jl @@ -5,7 +5,7 @@ const SubBlockSkylineMatrix{T,LL,UU,R1,R2} = -function add_bandwidths(A::AbstractBlockBandedMatrix,B::AbstractBlockBandedMatrix) +function add_bandwidths(A, B) Al,Au = colblockbandwidths(A) Bl,Bu = colblockbandwidths(B) @@ -24,7 +24,7 @@ function add_bandwidths(A::AbstractBlockBandedMatrix,B::AbstractBlockBandedMatri l,u end -function add_bandwidths(A::BlockBandedMatrix,B::BlockBandedMatrix) +function add_bandwidths(A::BlockBandedMatrix, B::BlockBandedMatrix) l,u = blockbandwidths(A) .+ blockbandwidths(B) Fill(l,blocksize(B,2)), Fill(u,blocksize(B,2)) end diff --git a/test/test_adjtransblockbanded.jl b/test/test_adjtransblockbanded.jl index bf531b2..a9ebc52 100644 --- a/test/test_adjtransblockbanded.jl +++ b/test/test_adjtransblockbanded.jl @@ -63,6 +63,18 @@ import BlockBandedMatrices: BandedBlockBandedRowMajor, BandedBlockBandedRows, @test rowsupport(E2, 1) == 1:0 @test colsupport(E2', 1) == 1:0 end + + @testset "Adj*BlockBanded" begin + R = BlockBandedMatrix{Float64}(undef, [1,1,2,2,3], 1:2:9, (0,0)); fill!(R, 0) + for K = 1:N + for k = 1:(K÷2) + R[Block(K,K)[k,2k-1]] = R[Block(K,K)[k,2K-2k+1]] = 1/sqrt(2) + end + isodd(K) && (R[Block(K,K)[K÷2+1,K]] = 1) + end + @test R'R == Matrix(R)'R + @test R*R' ≈ I + end end end # module