Description
Is your feature request related to a use case or problem? Please explain
A 1x1 MatrixGate, like cirq.MatrixGate(np.array([[1j]]))
, is equivalent to a global phase gate. A controlled global phase gate decomposes to Rz
plus a phase. A controlled 1x1 MatrixGate does not decompose. It seems that it should, and would be nice if it did.
Describe the solution you would prefer
Currently ControlledGate._decompose_
has a specific block for isinstance(subgate, GlobalPhaseGate)
. However, the logic there could apply to any gate that's equivalent to a global phase gate. i.e. any gate that has a 1x1 unitary. Thus instead of the isinstance
check, that condition could be changed to a check that there's a 1x1 unitary. The only subsequent change would be that you'd have to get the phase from that unitary (just u[0][0]
) instead of from the coefficient
member that only exists on GlobalPhaseGate.
This would allow controlled 1x1 MatrixGates to decompose, and get rid of an ugly isinstance
check, so two improvements for the price of one.
How urgent is this for you? Is it blocking important work?
P3 – I'm not really blocked by it; it's an idea I'm proposing based on principle