Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2-arg show for Symmetric/Hermitian and triangular #56013

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jishnub
Copy link
Contributor

@jishnub jishnub commented Oct 6, 2024

After this,

julia> A = rand(2,2);

julia> H = Hermitian(A)
2×2 Hermitian{Float64, Matrix{Float64}}:
 0.889108  0.264298
 0.264298  0.234985

julia> println(H)
Hermitian([0.8891078167175059 0.26429820656950753; 0.26429820656950753 0.23498548977257172])

julia> S = Symmetric(A)
2×2 Symmetric{Float64, Matrix{Float64}}:
 0.889108  0.264298
 0.264298  0.234985

julia> println(S)
Symmetric([0.8891078167175059 0.26429820656950753; 0.26429820656950753 0.23498548977257172])

julia> U = UpperTriangular(A)
2×2 UpperTriangular{Float64, Matrix{Float64}}:
 0.889108  0.264298
          0.234985

julia> println(U)
UpperTriangular([0.8891078167175059 0.26429820656950753; 0.0 0.23498548977257172])

julia> U = UnitUpperTriangular(A)
2×2 UnitUpperTriangular{Float64, Matrix{Float64}}:
 1.0  0.264298
     1.0

julia> println(U)
UnitUpperTriangular([1.0 0.26429820656950753; 0.0 1.0])

julia> L = LowerTriangular(A)
2×2 LowerTriangular{Float64, Matrix{Float64}}:
 0.889108    
 0.2504    0.234985

julia> println(L)
LowerTriangular([0.8891078167175059 0.0; 0.2503997651590879 0.23498548977257172])

julia> L = UnitLowerTriangular(A)
2×2 UnitLowerTriangular{Float64, Matrix{Float64}}:
 1.0       
 0.2504  1.0

julia> println(L)
UnitLowerTriangular([1.0 0.0; 0.2503997651590879 1.0])

The displayed form is now a valid constructor, and may be copy-pasted to reconstruct the object.

@jishnub jishnub added the linear algebra Linear algebra label Oct 6, 2024
@nsajko nsajko added the display and printing Aesthetics and correctness of printed representations of objects. label Oct 6, 2024
@jishnub jishnub marked this pull request as draft October 7, 2024 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. linear algebra Linear algebra
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants