Open
Description
This method is useful in general, as it allows custom types to hook into the structure-preserving broadcast mechanism without having to define their own methods for each function. As an example:
julia> using FillArrays, LinearAlgebra
julia> Diagonal(1:4) .+ Zeros(4,4)
4×4 Matrix{Float64}:
1.0 0.0 0.0 0.0
0.0 2.0 0.0 0.0
0.0 0.0 3.0 0.0
0.0 0.0 0.0 4.0
julia> LinearAlgebra.fzero(x::Zeros) = zero(eltype(x))
julia> Diagonal(1:4) .+ Zeros(4,4)
4×4 Diagonal{Float64, Vector{Float64}}:
1.0 ⋅ ⋅ ⋅
⋅ 2.0 ⋅ ⋅
⋅ ⋅ 3.0 ⋅
⋅ ⋅ ⋅ 4.0
Perhaps this could also be done through an isstructuredmatrix
trait that is made public.