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

better printing for MPS #266

Open
starsfordummies opened this issue Dec 2, 2024 · 1 comment
Open

better printing for MPS #266

starsfordummies opened this issue Dec 2, 2024 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@starsfordummies
Copy link
Contributor

now that we have forms and all that, it would be nice to have it shown when we print an mps. We could print also the info on the bond dimension (see #181 ) , maybe on the physical dimension as well

linkdims(psi) = [size(psi,link) for link in inds(psi, set=:inner)]
maxlinkdim(psi) = maximum(linkdims(psi))
function Base.show(io::IO, tn::T) where {T<:Tenet.AbstractQuantum}
               return print(io, "$T (inputs=$(nsites(tn; set=:inputs)), outputs=$(nsites(tn; set=:outputs))), chimax=$(maxlinkdim(tn)), form=$(form(psi))")
               end
julia> psi = rand(MPS, n=10, maxdim=128)
julia> psi
MPS (inputs=0, outputs=10), chimax=32, form=MixedCanonical(1)

Ideally even printing linkdims(psi) (so the bond dimension on all tensors) would be useful, but right now if I just print them like this it returns it in sparse ordering, which I don't like (should sort it appropriately but I'm not too sure how )

julia> psi = rand(MPS, n=10, maxdim=128)
MPS (inputs=0, outputs=10), chimax=32, form=MixedCanonical(1)

julia> print(linkdims(psi))
[2, 2, 16, 8, 4, 8, 16, 4, 32]
@starsfordummies starsfordummies added the enhancement New feature or request label Dec 2, 2024
@mofeing mofeing added the good first issue Good for newcomers label Dec 2, 2024
@mofeing
Copy link
Member

mofeing commented Dec 2, 2024

I like the idea of prettier printing for MPS, MPO and other types in general.

About printing all the physical and virtual dimensions is not sth that I'm convinced because it will be big when we have a lot sites. But we should have sth like the following working:

size.(Ref(tn), inds(tn; set=:physical))
size.(Ref(tn), inds(tn; set=:virtual))

# or
size(tn; set=:physical)
size(tn; set=:bonds)

In general, the printing should just provide superficial info in a short message. But I agree that additional info should be easy to query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants