mimiqcircuits.operations.gates.standard.swap¶
SWAP gate.
Classes
|
Two qubit SWAP gate. |
- class GateSWAP[source]¶
Bases:
GateTwo qubit SWAP gate.
Exchanges the states of the two qubits.
Matrix Representation
\[\begin{split}\operatorname{SWAP} = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}\]Examples
>>> from mimiqcircuits import * >>> GateSWAP() SWAP >>> GateSWAP().matrix() [1.0, 0, 0, 0] [0, 0, 1.0, 0] [0, 1.0, 0, 0] [0, 0, 0, 1.0] >>> c = Circuit().push(GateSWAP(), 0, 1) >>> c 2-qubit circuit with 1 instruction: └── SWAP @ q[0:1] >>> GateSWAP().power(2), GateSWAP().inverse() (⨷ ² ID, SWAP) >>> GateSWAP().decompose() 2-qubit circuit with 3 instructions: ├── CX @ q[0], q[1] ├── CX @ q[1], q[0] └── CX @ q[0], q[1]
See also
GateISWAP,GateCSWAP