From 29989e569239c6db860dd716d1f89c01fec6b588 Mon Sep 17 00:00:00 2001 From: nhz2 Date: Sun, 27 Sep 2026 15:37:06 -0400 Subject: [PATCH] Zero-fill block_starts instead of leaving unstored slots undef For a BlockSkylineMatrix with ragged block bandwidths, block_starts is a BandedMatrix with bandwidths (maximum(l), maximum(u)), so it has in-band slots for blocks that a narrower column does not store. These were allocated undef and never written, so reading them gave garbage. They now read as 0, like the out-of-band entries. Co-Authored-By: Claude Opus 5.5 (1M context) --- src/BlockSkylineMatrix.jl | 3 ++- test/test_blockskyline.jl | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/BlockSkylineMatrix.jl b/src/BlockSkylineMatrix.jl index ccbc7f2..2c4edb5 100644 --- a/src/BlockSkylineMatrix.jl +++ b/src/BlockSkylineMatrix.jl @@ -6,7 +6,8 @@ checkbandwidths(N, M, l::AbstractVector{Int}, u::AbstractVector{Int}) = function bb_blockstarts(ax, l::AbstractVector{Int}, u::AbstractVector{Int}) N,M = blocksize.(ax,1) L,U = maximum(l), maximum(u) - b_start = BandedMatrix{Int}(undef, (N, M), (L, U)) + # zero-filled so in-band slots for blocks outside a column's own band read as 0 + b_start = BandedMatrix(Zeros{Int}(N, M), (L, U)) -L > U && return b_start checkbandwidths(N, M, l, u) diff --git a/test/test_blockskyline.jl b/test/test_blockskyline.jl index 5385648..79a3e1c 100644 --- a/test/test_blockskyline.jl +++ b/test/test_blockskyline.jl @@ -165,6 +165,14 @@ Random.seed!(0) s = split(sprint(show, "text/plain", B), '\n')[2] @test s == " 1 │ 0 0 │ ⋅ ⋅ ⋅ │ ⋅ ⋅ ⋅ ⋅" end + + @testset "block_starts" begin + # block (3,2) is in the band of block_starts but not stored, so must be 0 + bs = BlockBandedMatrices.BlockSkylineSizes([2,3,4], [1,2,3], [2,0,0], [0,1,1]) + @test Matrix(bs.block_starts) == [1 10 0; + 3 12 20; + 6 0 23] + end end end # module