Repository navigation
fix: schmidt_rank for unequal subsystem dimensions - #1981
Open
SANJANAKUMARI83 wants to merge 4 commits into
Open
SANJANAKUMARI83 wants to merge 4 commits into
SANJANAKUMARI83 wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Closes #1980
schmidt_rankreshaped state vectors withnp.reshape(rho, dim[::-1]). The reversed shape is what MATLAB's column-majorreshapeneeds, but NumPy is row-major, so whenever the two subsystems have different dimensions the coefficient matrix was scrambled. For square dimensions it only produced a transpose, which is why the existing tests passed. Since the operator Schmidt rank goes through the same code,is_separablewas also reporting some product states on unequal dimensions as entangled.While testing this I also noticed the pure-state branch of
is_separablereports the operator Schmidt rank in its message (e.g. "Schmidt rank 4" for a Bell state, which is the square of the actual Schmidt rank). It now takes the state vector from the rank-1 density matrix and reports its Schmidt rank. The separable / entangled verdict in that branch doesn't change.Changes
schmidt_rank: reshape withnp.reshape(rho, dim)so the coefficient matrix matchesnp.kronordering.is_separable: in the pure-state branch, compute the Schmidt rank of the state vector (top eigenvector) instead of the density matrix.schmidt_rankon unequal dimensions (product and entangled states,[2, 3],[3, 2], integerdim) and for the operator Schmidt rank on[2, 3].is_separablepure-state message on 2x2, 3x3 and 2x3, including a 2x3 product state that was previously reported as entangled.The new tests fail on
master(10 of 13) and pass with this change. I also checkedschmidt_rankagainst the rank ofv.reshape(dA, dB)(and of the realigned matrix for the operator version) on 80 random pure states over (2,2), (2,3), (3,2), (2,4), (4,2), (3,3) and (3,5): 40 disagreed onmaster, all with unequal dimensions, and 0 disagree with this change.sk_normalso callsschmidt_rankon vectors, so it benefits from the fix for unequal dimensions too.Checklist
rufffor errors related to code style and formatting.pytest. (Ran the CI command,pytest -m "not slow": 3767 passed.)