quantum gate directory

Gates Groups SDKs GitHub
$\mathrm{CSWAP}$

controlled· 3 qubits

Fredkin

Controlled swap of two target qubits conditioned on a single control qubit.

Open in Quirk ↗ hermitian

The Fredkin (CSWAP) gate swaps the two target qubits when the control qubit is in the $|1\rangle$ state, and acts as identity when the control is $|0\rangle$.

$$ \mathrm{CSWAP} = \begin{bmatrix} 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 \end{bmatrix} $$

Properties

  • Self-inverse and Hermitian: $\mathrm{CSWAP}^\dagger = \mathrm{CSWAP}$.
  • Classical reversible and conservative; it preserves Hamming weight in the computational basis.
  • Can be decomposed into CNOT and Toffoli gates or into a small set of two-qubit gates.

Usage

  • Conditional routing and permutation of qubits in a circuit.
  • Reversible classical logic and quantum algorithms that require controlled swaps.

Also written

  • $\mathrm{CSWAP}$
  • $\text{Fredkin}$
  • $\text{controlled-}SWAP$

Related

  • Controlled version of SWAP

Groups

  • orthogonal
  • permutation
  • number-preserving

Data

  • This gate as JSON
  • Edit this page on GitHub

The unitary, drawn

Every entry of the matrix as a disc. The area is the transition probability $|U_{jk}|^2$; the colour and the hand are the phase. Rows are outputs $\langle j|$, columns inputs $|k\rangle$, in the computational basis.

Phase

Disc area $= |U_{jk}|^2$. Hover an entry for its value, or take the JSON.

SDK support

How to call this gate in each framework. Hover a ⓘ for a note; the support matrix compares every gate at once.

SDKName
Qiskit qiskit.circuit.library.CSwapGate
PennyLane pennylane.CSWAP
Cirq cirq.CSWAP ⓘ
Q# — ⓘ
PyQuil pyquil.gates.CSWAP
Braket braket.circuits.gates.CSwap
BQSKit — ⓘ
Qibo — ⓘ
pytket pytket.circuit.OpType.CSWAP
Stim —
OpenQASM stdgates.inc: cswap

← All gates

gate.directory made by nts $\oplus$ rdls