From 4763c49ce187519ee208a2384e54243fd0961ccf Mon Sep 17 00:00:00 2001 From: Jishnu Bhattacharya Date: Sun, 11 May 2025 20:33:45 +0530 Subject: [PATCH] `BandIndex` and inbounds-propagation in `diagzero` --- src/diagonal.jl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/diagonal.jl b/src/diagonal.jl index 3f72c16c..2b1df153 100644 --- a/src/diagonal.jl +++ b/src/diagonal.jl @@ -192,8 +192,8 @@ Return the appropriate zero element `A[i, j]` corresponding to a banded matrix ` """ diagzero(A::AbstractMatrix, i, j) = zero(eltype(A)) @propagate_inbounds diagzero(A::AbstractMatrix{M}, i, j) where {M<:AbstractMatrix} = - zeroslike(M, axes(A[i,i], 1), axes(A[j,j], 2)) -diagzero(A::AbstractMatrix, inds...) = diagzero(A, to_indices(A, inds)...) + zeroslike(M, axes(A[BandIndex(0, i)], 1), axes(A[BandIndex(0, j)], 2)) +@propagate_inbounds diagzero(A::AbstractMatrix, inds...) = diagzero(A, to_indices(A, inds)...) # dispatching on the axes permits specializing on the axis types to return something other than an Array zeroslike(M::Type, ax::Vararg{Union{AbstractUnitRange, Integer}}) = zeroslike(M, ax) """