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.

SwapGate.assemble()

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.

SwapGate.inverse()

Return inverse Swap gate (itself).

SwapGate.is_parameterized()

Return True .IFF.

SwapGate.mirror()

DEPRECATED: use instruction.reverse_ops().

SwapGate.power(exponent)

Creates a unitary gate as gate^exponent.

SwapGate.qasm()

Return a default OpenQASM string for the instruction.

SwapGate.repeat(n)

Creates an instruction with gate repeated n amount of times.

SwapGate.reverse_ops()

For a composite instruction, reverse the order of sub-instructions.

SwapGate.to_matrix()

Return a numpy.array for the SWAP gate.