rewritten "naive" alghoritm to work in place #115
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've rewritten the "naive" algorithm to modify the mps in place. As discussed on the forum ITensorDiscourseGroup/2271 this implementation is more memory efficient respect the previous one, without impacting the stability of the algorithm. As discussed on the forum the returned MPS is always going to be right orthogonal, this was already true for the
densitymatrix
algorithm and for thenaive
in the casetruncate=true
, while fortruncate=false
the returned MPS was not gauged.Details on the Implementation
The implementation uses 2 MPS, one is the MPS passed as input, while another one is created with the same size, but no additional ITensors are created (Imagine it just as a Vector of pointers to Objects, which is what they actually are on a lower level). The data field of the 2 MPSs are used in a stack like manner, in particular ITensors are popped from one, elaborated an the result pushed in the other, in this way the ITensors are never referenced twice, allowing for the garbage collector to act more freely.
I'm gonna cite the comment also present in the code since I think it explains in good detail the implementation:
Other changes
Instead of creating an "apply!" version I preferred to create a different utility function which I called
evolve!
, in a way to make it clearer that the idea is to evolve the MPS by applying the MPO to it, for the same reason the order of the arguments is reversed, putting the MPS first.