qleap.Swap

class qleap.Swap(q1, q2, control=None)

Swap is a class that represents the Swap gate operation in the QLeap framework.

The Swap gate switches the state of 2 qubits. For example, it maps \(|01\rangle\) to math:|10rangle and vice versa. An optional control qubit makes this a controlled swap gate, which will only perform the operation if the control is in the state \(|1\rangle\).

__init__(q1, q2, control=None)

Creates a Swap instance that represents a Swap gate operation with the two given qubits. If an optional control qubit is given, this becomes a controlld swap gate.

Parameters:
  • q1 (QState) – The first qubit in the swap operation.

  • q2 (QState) – The second qubit in the swap operation

  • control (QState, optional) – The control qubit, which if not None, makes this a controlled swap, by default None.

Raises:

ValueError – If q1, q2, or the control argument contain more than one qubit.

Methods

__init__(q1, q2[, control])

Creates a Swap instance that represents a Swap gate operation with the two given qubits.