From 0dfe2e2d7182e675f58810985934cd904d2acb76 Mon Sep 17 00:00:00 2001 From: MilesCranmer Date: Fri, 10 May 2024 21:40:17 +0100 Subject: [PATCH] Let `diagzero` to propagate non-typed information where relevant --- stdlib/LinearAlgebra/src/diagonal.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/LinearAlgebra/src/diagonal.jl b/stdlib/LinearAlgebra/src/diagonal.jl index bbeb2a50a9a93..bdc3c7e363ca2 100644 --- a/stdlib/LinearAlgebra/src/diagonal.jl +++ b/stdlib/LinearAlgebra/src/diagonal.jl @@ -184,7 +184,7 @@ end end r end -diagzero(::Diagonal{T}, i, j) where {T} = zero(T) +diagzero(D::Diagonal{T}, i, j) where {T} = haszero(T) ? zero(T) : zero(first(D.diag)) diagzero(D::Diagonal{<:AbstractMatrix{T}}, i, j) where {T} = zeros(T, size(D.diag[i], 1), size(D.diag[j], 2)) function setindex!(D::Diagonal, v, i::Int, j::Int)