From f4b055c9c3045ac8be271505df97f4980b44b643 Mon Sep 17 00:00:00 2001 From: Sheehan Olver Date: Tue, 5 May 2026 16:43:16 +0100 Subject: [PATCH] avoid calls to axes to make sparse faster --- ext/BlockBandedMatricesSparseArraysExt.jl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ext/BlockBandedMatricesSparseArraysExt.jl b/ext/BlockBandedMatricesSparseArraysExt.jl index 442415e..e52d549 100644 --- a/ext/BlockBandedMatricesSparseArraysExt.jl +++ b/ext/BlockBandedMatricesSparseArraysExt.jl @@ -11,13 +11,14 @@ function sparse(A::BandedBlockBandedMatrix) i = Vector{Int}() j = Vector{Int}() z = Vector{eltype(A)}() + m_ax,n_ax = axes(A) for J = blockaxes(A,2), K = blockcolsupport(A, J) B = view(A, K, J) ĩ = _banded_rowval(B) j̃ = _banded_colval(B) z̃ = _banded_nzval(B) - ĩ .+= first(axes(A,1)[K])-1 - j̃ .+= first(axes(A,2)[J])-1 + ĩ .+= first(m_ax[K])-1 + j̃ .+= first(n_ax[J])-1 append!(i, ĩ) append!(j, j̃) append!(z, z̃)