Skip to content

In-place broadcast on Symmetric and Hermition fails against constants #646

@ChrisRackauckas

Description

@ChrisRackauckas
A = Symmetric(Diagonal(rand(2)))
A .= A ./ 2
ERROR: ArgumentError: Cannot set a non-diagonal index in a symmetric matrix
Stacktrace:
 [1] setindex! at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\LinearAlgebra\src\symmetric.jl:208 [inlined]
 [2] _setindex! at .\abstractarray.jl:1050 [inlined]
 [3] setindex! at .\abstractarray.jl:1020 [inlined]
 [4] macro expansion at .\broadcast.jl:843 [inlined]
 [5] macro expansion at .\simdloop.jl:73 [inlined]
 [6] copyto! at .\broadcast.jl:842 [inlined]
 [7] copyto! at .\broadcast.jl:797 [inlined]
 [8] materialize!(::Symmetric{Float64,Diagonal{Float64,Array{Float64,1}}}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{2},Nothing,typeof(/),Tuple{Symmetric{Float64,Diagonal{Float64,Array{Float64,1}}},Int64}}) at .\broadcast.jl:756
 [9] top-level scope at none:0

though that should be harmless since if it was symmetric before, that would have to keep the same values in the end. Same happens with Hermitian.

Metadata

Metadata

Assignees

No one assigned

    Labels

    broadcastApplying a function over a collection

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions