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

Override gate.controlled() for GlobalPhaseGate to return a ZPowGate #6073

Merged
merged 10 commits into from
May 10, 2023

Conversation

tanujkhattar
Copy link
Collaborator

ZPowGate, CZPowGate and CCZPowGate currently have specialized Gate.controlled() overrides such that cirq.Z.controlled() returns a cirq.CZ instead of a cirq.ControlledGate(sub_gate=cirq.Z). This is nice and useful for writing controlled versions of common gates.

This PR extends the same idea to GlobalPhaseGate, because a controlled GlobalPhaseGate is equivalent to applying a cirq.ZPowGate.

@tanujkhattar tanujkhattar requested review from a team, vtomole and cduck as code owners April 21, 2023 13:53
@CirqBot CirqBot added the size: S 10< lines changed <50 label Apr 25, 2023
@tanujkhattar tanujkhattar enabled auto-merge (squash) May 10, 2023 00:46
@tanujkhattar tanujkhattar merged commit a95f009 into quantumlib:master May 10, 2023
harry-phasecraft pushed a commit to PhaseCraft/Cirq that referenced this pull request Oct 31, 2024
…uantumlib#6073)

* Override gate.controlled() for GlobalPhaseGate to return a ZPowGate

* Test unitary equivalence

* Override controlled only if gate is not parameterized

* Fix typo

* Fix type check

* another attempt at fixing types

* Add a comment and additional tests
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.

3 participants