Skip to content

Structured matrices don't extend missing dimensions correctly in broadcasting #1063

Open
@jishnub

Description

@jishnub
julia> D1 = Diagonal([1]); D2 = Diagonal([1,2]);

julia> D1 .+ D2
2×2 Diagonal{Int64, Vector{Int64}}:
 2  
   3

julia> Matrix(D1) .+ D2
2×2 Matrix{Int64}:
 2  1
 1  3

Ideally, these should produce identical results.
In the structured case, the 1x1 matrix D1 isn't expanded to ones(size(D2)), but instead it's expanded to Diagonal(ones(Int, size(D2,1))). I'm unsure if there's a way to resolve this while preserving type-stability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collectionbugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions