# How to check if a quantum circuit can be constructed for a given matrix representation?

Let's say I have a matrix representation, e.g.

$$\begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \end{pmatrix}.$$

How can I determine whether a quantum circuit can be constructed given said matrix representation? Is unitarity a sufficient and necessary condition?

• In addition to the other, fuller, answers, your SWAP matrix is a permutation, which is also sufficient for being a quantum gate. Permutations happen to be necessary for being implementable as a classical reversible gate, which are subsets of quantum gates. Feb 3, 2021 at 3:08
• yes, effectively any universal quantum device can implement any unitary matrix up to arbitrary precision. Feb 10, 2021 at 14:12

Right. But when you build a quantum computer, you want to have a certain set of gates that you want to implement, and all other gates (unitary matrices) can be built from that set of gates. This is known as a universal set. Surprisingly (or not), it is quite small. One example of a universal set is: $$G = \{H, S, T, CNOT \}$$ where
$$H = \dfrac{1}{\sqrt{2}}\begin{pmatrix} 1 & 1\\ 1 & -1 \end{pmatrix}, \hspace{.25 cm} T =\begin{pmatrix} 1 & 0\\ 0 & e^{i\pi/4} \end{pmatrix}, \hspace{.25 cm} S = \begin{pmatrix} 1 & 0\\ 0 & i \end{pmatrix}, \hspace{.25 cm} CNOT = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \end{pmatrix}$$
This is just an example of one of many universal sets. These are the native gates you can say on your quantum hardware. For instance, on IBM hardware, the native gates are: { CNOT, I, RZ, SX, X }. The point is every unitary matrix can be approximated to an arbitrary, $$\epsilon$$, error using those gates. This formed your quantum circuit.