-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Conversation
cirq-core/cirq/ops/common_gates.py
Outdated
|
||
Args: | ||
exponent: The t in gate**t. Determines how much the eigenvalues of | ||
the gate are scaled by. For example, eigenvectors phased by -1 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.)
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.
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.
As advertised. Everything except the "dimension" part is copied from the EigenGate constructor docstring.
Also opened #5647 for adding similar functionality + docs to YPowGate.