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

Add normalize!(::MPS/MPO) #500

Closed
mtfishman opened this issue Sep 22, 2020 · 2 comments
Closed

Add normalize!(::MPS/MPO) #500

mtfishman opened this issue Sep 22, 2020 · 2 comments
Assignees
Labels
api Issues related to the interface enhancement New feature or request mps Issues related to MPS/MPO functionality
Milestone

Comments

@mtfishman
Copy link
Member

mtfishman commented Sep 22, 2020

Add normalize!(::MPS/MPO). It should normalize just the center sites. Also, it should carefully handle the normalization if the total norm of the MPS/MPO diverges (i.e. for an ungauged MPS/MPO with many sites). It can also return the norm per site.

Perhaps the API could be:

sitenorms = []
normalize!(psi; sitenorms! = sitenorms)

where the norm per site gets appended to the vector sitenorms (to keep the convention that in-place functions return the object being modified).

@mtfishman
Copy link
Member Author

mtfishman commented Sep 22, 2020

Also to add on: I kind of like the idea of passing outputs that get overwritten as keyword arguments, since it gives more flexibility to the API, like if you want to add more things to get output. In a function like normalize!, you could imagine also returning the log of the total normalization, for example, as a keyword argument lognorm! = lognorm. This function may not be the best example, but other functions like svd or MPS/MPO functions that truncate may have all sorts of different outputs a user might want. Returning them as a tuple kind of locks-in the API, since once you choose the outputs then it is hard to change it without breaking code. Keyword arguments are more flexible.

@mtfishman
Copy link
Member Author

mtfishman commented Sep 22, 2020

This would be useful in a function like MPS(::ITensor, sites), where you expect it to output the MPS, but then you might also want the Spectrum object for each bond, if truncation is performed, so it would be something like:

s = siteinds("S=1/2", 3)
A = randomITensor(s...)
spectra = []
ψ = MPS(A, s; spectra! = spectra)

so that spectra would store the Spectrum objects for each bond of the MPS.

@mtfishman mtfishman self-assigned this Oct 7, 2020
@mtfishman mtfishman added api Issues related to the interface enhancement New feature or request mps Issues related to MPS/MPO functionality labels Oct 7, 2020
@mtfishman mtfishman added this to the v0.2.0 milestone Oct 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Issues related to the interface enhancement New feature or request mps Issues related to MPS/MPO functionality
Projects
None yet
Development

No branches or pull requests

1 participant