My question is very simple. I know there is a method to add a control to previously defined gates. I saw in the API of cirq that there is a command Controlled gate (here). I'm not understanding though how would this work. Suppose for example I want to add a control to an XPowGate from cirq. How would I write this in a program and how would I define the control qubit and the qubit over which I want to act?
In 0.4.0 (current release), you make controlled versions of arbitrary gates by wrapping them with
controlled_x = cirq.ControlledGate(cirq.X) return controlled_x.on(control_qubit, target_qubit)
Controlled gates support most convenience operations, such as asking for the unitary matrix with
cirq.unitary(...) or raising to a power. (There are also several built-in controlled gates for specific gates, such as