Skip to content

Broadcast with LowerTriangular, UpperTriangular, and Diagonal gives Diagonal #33397

@sethaxen

Description

@sethaxen

Broadcasting addition for UpperTriangular, LowerTriangular, and Diagonal produces a Diagonal. Note that normal addition is fine, and if either of these matrices are excluded, the result is fine.

julia> using Random, LinearAlgebra
julia> Random.seed!(42);
julia> U = UpperTriangular(randn(3,3));
julia> L = LowerTriangular(randn(3,3));
julia> D = Diagonal(randn(3));
julia> U+L+D
3×3 Array{Float64,2}:
 0.857936  -0.299484  -0.468606
 1.08238    2.41289    0.156143
 0.187028   0.367563  -5.28356 
julia> U.+L.+D
3×3 Diagonal{Float64,Array{Float64,1}}:
 0.857936                 
          2.41289         
                  -5.28356

Version info:

julia> versioninfo()
Julia Version 1.3.0-rc2.0
Commit a04936e3e0 (2019-09-12 19:49 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin18.6.0)
  CPU: Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, haswell)

Also confirmed on 1.2.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]broadcastApplying a function over a collectionbugIndicates an unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions