CSWAP

pyquil.gates.CSWAP(control, target_1, target_2)[source]

Produces a controlled-SWAP gate. This gate conditionally swaps the state of two qubits:

CSWAP = [[1, 0, 0, 0, 0, 0, 0, 0],
         [0, 1, 0, 0, 0, 0, 0, 0],
         [0, 0, 1, 0, 0, 0, 0, 0],
         [0, 0, 0, 1, 0, 0, 0, 0],
         [0, 0, 0, 0, 1, 0, 0, 0],
         [0, 0, 0, 0, 0, 0, 1, 0],
         [0, 0, 0, 0, 0, 1, 0, 0],
         [0, 0, 0, 0, 0, 0, 0, 1]]
Parameters
  • control (Union[Qubit, QubitPlaceholder, FormalArgument, int]) – The control qubit.

  • target_1 (Union[Qubit, QubitPlaceholder, FormalArgument, int]) – The first target qubit.

  • target_2 (Union[Qubit, QubitPlaceholder, FormalArgument, int]) – The second target qubit. The two target states are swapped if the control is in the |1> state.

Return type

Gate