Symmetric(::Symmetric) and Hermitian(::Hermitian) with bug #597
Open
Description
opened on Jan 23, 2019
I think it is common understanding, that for X::AbstractMatrix
.
Symmetric(X, uplo) == Symmetric(Matrix(X), uplo)
Symmetric(X) == Symmetric(X, :U)
Actually we observe
julia> VERSION
v"1.2.0-DEV.212"
julia> A = [1 2; 3 4]
2×2 Array{Int64,2}:
1 2
3 4
julia> X = Symmetric(A, :L)
2×2 Symmetric{Int64,Array{Int64,2}}:
1 3
3 4
julia> Symmetric(X) == Symmetric(X, :U) # result contradicts 2.
ERROR: ArgumentError: Cannot construct Symmetric; uplo doesn't match
Stacktrace:
[1] Symmetric(::Symmetric{Int64,Array{Int64,2}}, ::Symbol) at
/home/julia/julia/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/symmetric.jl:162
[2] top-level scope at REPL[87]:1
julia> Symmetric(X) == Symmetric(Matrix(X))
true
julia> Symmetric(Matrix(X), :U) # result contradicts 1.
2×2 Symmetric{Int64,Array{Int64,2}}:
1 3
3 4
julia> Symmetric(Matrix(X), :L)
2×2 Symmetric{Int64,Array{Int64,2}}:
1 3
3 4
I think, we should have
Symmetric(X::Symmetric, uplo::Symbol=:U) = X
independent of uplo
and X.uplo
.
The same is true for Hermitian
Metadata
Assignees
Labels
No labels
Activity