-
Notifications
You must be signed in to change notification settings - Fork 1
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
Comments
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. |
I'm ok with the second option (no idea how the Ref() works but the easier the commands the better) so for the MPS something like the Base.show() I wrote above would be ok for you ? I was also thinking about what to do for the physical dimension - in 90% of the cases it's equal for every site so it makes sense to print it once, though there are counterexamples, maybe one could print only the |
it actually has nothing to do with e.g. size.(Ref(tn), inds(tn; set=:physical))
# is equal to
[
size(tn, :A),
size(tn, :B),
...
]
Yes, but
Printing a |
What is the simplest way to print the sizes of all tensors in the MPS ?
something that returns |
If you don't mind the |
ah nice! but you say order because in principle they might be in the wrong order ? |
And even julia> psi2 = MPS([rand(2,2),rand(2,2,4),rand(2,4,7),rand(3,7,4),rand(4,4)])
julia> canonize!(psi2)
julia> size.(psi2)
9-element Vector{Tuple{Int64, Vararg{Int64}}}:
(2, 2)
(2, 2, 4)
(4, 2, 7)
(7, 3, 4)
(4, 4)
(2,)
(4,)
(7,)
(4,) |
I see, then this doesn't work, ideally it would be good to have something that gets the size of the tensor in order with the Sites, and also prints the inds in the same order for all of them like eg. left,phys,right - here it's not clear anymore:
|
I remember I needed once this function you mean and I quickly did this nicely written function: julia> size_tensors(ψ) =Tenet.size.(vec(vcat([Tensor(permutedims(tensors(ψ, at=Site(1)), (inds(ψ, at=Site(1)), inds(ψ; at=Site(1), dir=:right))), inds(tensors(ψ, at=Site(1)))), tensors(ψ, between=(Site(1), Site(2)))],
[[Tensor(permutedims(tensors(ψ, at=Site(i)), (inds(ψ; at=Site(i), dir=:left), inds(ψ, at=Site(i)), inds(ψ; at=Site(i), dir=:right))), inds(tensors(ψ, at=Site(i)))), tensors(ψ, between=(Site(i), Site(i+1)))] for i in 2:nsites(ψ)-1]...,
[Tensor(permutedims(tensors(ψ, at=Site(nsites(ψ))), (inds(ψ; at=Site(nsites(ψ)), dir=:left), inds(ψ, at=Site(nsites(ψ))))), inds(tensors(ψ, at=Site(nsites(ψ)))))])))
julia> psi2 = MPS([rand(2,2),rand(2,2,4),rand(2,4,7),rand(3,7,4),rand(4,4)]); canonize!(psi2)
julia> size_tensors(psi2)
9-element Vector{Tuple{Int64, Vararg{Int64}}}:
(2, 2)
(2,)
(2, 2, 4)
(4,)
(4, 2, 7)
(7,)
(7, 3, 4)
(4,)
(4, 4) Which works for the |
@starsfordummies just out of curiosity, is there sth you're trying? like what's your motivation for getting the size of tensors in order? is it just for debugging or are you trying sth else? btw, having a |
mostly for debugging I think it'd be nice to check if anything funky is going on with the MPS tensors. Doing some |
yes, but we can also use if you want it for debugging, we can maybe add support for About.jl |
or maybe something like this which doesn't touch the tensors, no ?
|
yeah, but I prefer not filling Tenet with hundreds of different functions. There's no problem into adding this |
But maybe this is useful to have without extensions, right? We can talk about it in the next meeting. |
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
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 )
The text was updated successfully, but these errors were encountered: