0

I have a two-qubit gate with below unitary:


    def _unitary_(self):
        st = np.sin(self.theta)
        ct = np.cos(self.theta)
        ei = np.exp(1j*self.phi)
        emi = np.exp(-1j*self.phi)
    return np.array([
        [1.,        0,          0,  0],
        [0,         ct,     ei*st,  0],
        [0,         emi*st,   -ct,  0],
        [0,         0,          0,  1.]
    ]
    )

I want to build a three-qubit gate in which one qubit serves as the control qubit on the above two-qubit gate while the gate is applied on the other two qubits.

Here is an example of such gate: Say the gate is applied on q0, q1, and q2 where q0 is the control qubit. The above 4*4 unitary should be applied to q1 and q2 if and only if q0 is 0.

How would the unitary of such three-qubit gate look like? (I'm doing this in Cirq)

Amin
  • 47
  • 4

1 Answers1

1

MyTwoQubitGate().on(q1, q2).controlled_by(c)

or

MyTwoQubitGate().controlled().on(c, q1, q2)

Craig Gidney
  • 36,389
  • 1
  • 29
  • 95
  • Thanks. Two follow up questions:
    1. What if I have more than one control qubit for my MyTwoQubitGate?
    2. What if some of the control qubits check for 0 and some others check for 1?

    I'm interested to know if Cirq has features to allow above two cases.

    – Amin Jul 16 '20 at 15:03
  • I think I found the answer: https://cirq.readthedocs.io/en/stable/generated/cirq.ControlledGate.html#cirq.ControlledGate – Amin Jul 16 '20 at 15:20