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

Document dimension of X/ZPowGate #5648

Merged
merged 4 commits into from
Jul 8, 2022
Merged

Document dimension of X/ZPowGate #5648

merged 4 commits into from
Jul 8, 2022

Conversation

95-martin-orion
Copy link
Collaborator

As advertised. Everything except the "dimension" part is copied from the EigenGate constructor docstring.

Also opened #5647 for adding similar functionality + docs to YPowGate.


Args:
exponent: The t in gate**t. Determines how much the eigenvalues of
the gate are scaled by. For example, eigenvectors phased by -1
Copy link
Collaborator

@viathor viathor Jul 1, 2022

Choose a reason for hiding this comment

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

s/scaled/phased/

The word "scaled" suggests a possible change to absolute value (which does not change - all eigenvalues of a unitary gate have unit absolute value).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, although this phrasing is copied from EigenGate. I'll update it there as well.


For example, `cirq.X**t` uses a `global_shift` of 0 but
`cirq.rx(t)` uses a `global_shift` of -0.5, which is why
`cirq.unitary(cirq.rx(pi))` equals -iX instead of X.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider updating the formula on line 75 above to account for global shift. Then you can refer to whatever letter you choose to use for global shift in the formula from the description of the argument here. This is what you effectively do on line 98 for exponent=t.

The benefit of this is that it allows the reader to unambiguously identify the gate they will get for given arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done, assuming I understood you correctly. PTAL

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, that's exactly it! :-)

I haven't checked that the math is correct. Might be worth calling np.linalg.eig(cirq.unitary(...)) on one of the gates with a few values of exponent and global_shift and check that the eigenvalues are correct.

Copy link
Collaborator

@viathor viathor Jul 8, 2022

Choose a reason for hiding this comment

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

(To be clear: I think we do this in unit tests, but doing it manually would give you an opportunity to compare the output against the math in the comment.)

@95-martin-orion 95-martin-orion added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 8, 2022
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 8, 2022
@CirqBot CirqBot merged commit 10eb638 into master Jul 8, 2022
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Jul 8, 2022
@CirqBot CirqBot deleted the xz-dim-docs branch July 8, 2022 19:02
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Jul 8, 2022
rht pushed a commit to rht/Cirq that referenced this pull request May 1, 2023
As advertised. Everything except the "dimension" part is copied from the EigenGate constructor docstring.

Also opened quantumlib#5647 for adding similar functionality + docs to YPowGate.
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
As advertised. Everything except the "dimension" part is copied from the EigenGate constructor docstring.

Also opened quantumlib#5647 for adding similar functionality + docs to YPowGate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: S 10< lines changed <50
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants