Skip to content

zero(::UnitUpperTriangular) throws #1613

@stevengj

Description

@stevengj
julia> using LinearAlgebra

julia> zero(UnitUpperTriangular(rand(5,5)))
ERROR: ArgumentError: cannot set index (1, 1) on the diagonal of a UnitUpperTriangular matrix to a non-unit value (0.0)

Seems like this should return an UpperTriangular matrix of zeros?

Similarly for UnitLowerTriangular.

Usually, we try to have zero return the same type, but that's not always the case (e.g. zero(1:2) returns a Vector), and here it is impossible. (See also #1050.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions