Skip to content

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