Skip to content

Fix convention of PolynomialTensor basis change#805

Open
aoowweenn wants to merge 4 commits into
quantumlib:mainfrom
aoowweenn:master
Open

Fix convention of PolynomialTensor basis change#805
aoowweenn wants to merge 4 commits into
quantumlib:mainfrom
aoowweenn:master

Conversation

@aoowweenn
Copy link
Copy Markdown

In general, we rotate a matrix M to M' is to apply a rotation matrix R: M' = R @ M @ R.T
The corresponding Einstein notation is
M'^{p_1p_2} = R^{p_1}{a_1} R^{p_2}{b_1} M^{a_1a_2}

aoowweenn and others added 2 commits October 10, 2022 12:42
In general, we rotate a matrix M to M' is to apply a rotation matrix R:
M' = R @ M @ R.T
The corresponding Einstein notation is
M'^{p_1p_2} = R^{p_1}_{a_1} R^{p_2}_{b_1} M^{a_1a_2}
@mhucka mhucka self-assigned this Jun 2, 2026
@mhucka
Copy link
Copy Markdown
Collaborator

mhucka commented Jun 2, 2026

@arettig Would you be able to take a look at this and check the technical correctness? (No rush.)

@mhucka mhucka requested a review from arettig June 4, 2026 03:55
Copy link
Copy Markdown
Contributor

@arettig arettig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good catch. The PolynomialTensor rotation code currently does not match the expression in the documentation. We should change this to match standard convention (and our own documentation), but this is a potentially breaking change for anyone using this function currently.

It would also be a good idea to change the 90 degree rotation test added in this PR to some different rotation as this test actually passes with the current (incorrect) implementation.

polynomial_tensor.rotate_basis(rotation_matrix_reverse)
self.assertEqual(polynomial_tensor, want_polynomial_tensor)

def test_rotate_basis_90deg(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test actually does not catch the bug you pointed out since for this specific case $$U^T M U$$ gives the same results as $$U M U^T$$. It would be a good idea to change this test to use a different basis rotation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants