# SwapGate¶

class SwapGate(label=None)[source]

The SWAP gate.

This is a symmetric and Clifford gate.

Circuit symbol:

q_0: ─X─
│
q_1: ─X─


Matrix Representation:

$\begin{split}SWAP = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}\end{split}$

The gate is equivalent to a state swap and is a classical logic gate.

$|a, b\rangle \rightarrow |b, a\rangle$

Create new SWAP gate.

Attributes

 SwapGate.decompositions Get the decompositions of the instruction from the SessionEquivalenceLibrary. SwapGate.definition Return definition in terms of other basic gates. SwapGate.label Return gate label SwapGate.params return instruction params.

Methods

 SwapGate.add_decomposition(decomposition) Add a decomposition of the instruction to the SessionEquivalenceLibrary. Assemble a QasmQobjInstruction SwapGate.broadcast_arguments(qargs, cargs) Validation and handling of the arguments and its relationship. SwapGate.c_if(classical, val) Add classical condition on register classical and value val. SwapGate.control([num_ctrl_qubits, label, …]) Return a (multi-)controlled-SWAP gate. SwapGate.copy([name]) Copy of the instruction. Return inverse Swap gate (itself). Return True .IFF. For a composite instruction, reverse the order of sub-gates. SwapGate.power(exponent) Creates a unitary gate as gate^exponent. Return a default OpenQASM string for the instruction. Creates an instruction with gate repeated n amount of times. Return a numpy.array for the SWAP gate.