Definition of all avalaible gates¶

In the following table, we list and give the definition of all available gates on the QLM.

Gate name
pyAQASM name
# qubits
Matrix
Hadamard
H
1
$ \begin{vmatrix} \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} \\ \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{2}} \\ \end{vmatrix}$
Pauli X
X
1
$ \begin{vmatrix} 0 & 1 \\ 1 & 0 \\ \end{vmatrix}$
Pauli Y
Y
1
$ \begin{vmatrix} 0 & -i \\ i & 0 \\ \end{vmatrix}$
Pauli Z
Z
1
$ \begin{vmatrix} 1 & 0 \\ 0 & -1 \\ \end{vmatrix}$
Identity
I
1
$ \begin{vmatrix} 1 & 0 \\ 0 & 1 \\ \end{vmatrix}$
Phase Shift
PH($\theta$)
1

$\forall \theta \in\rm I\!R$:

$\begin{vmatrix} 1 & 0 \\ 0 & e^{i\theta} \\ \end{vmatrix}$

Phase Shift gate of $\frac{\pi}{2}$
S
1
$ \begin{vmatrix} 1 & 0 \\ 0 & i \\ \end{vmatrix}$
Phase Shift gate of $\frac{\pi}{4}$
T
1
$ \begin{vmatrix} 1 & 0 \\ 0 & e^{i\frac{\pi}{4}} \\ \end{vmatrix}$
X Rotation
RX($\theta$)
1

$\forall \theta \in\rm I\!R$:

$\begin{vmatrix} \cos(\frac{\theta}{2}) & -i\sin(\frac{\theta}{2}) ~\\ -i\sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \\ \end{vmatrix}$

Y Rotation
RY($\theta$)
1

$\forall \theta \in\rm I\!R$:

$\begin{vmatrix} \cos(\frac{\theta}{2}) & -\sin(\frac{\theta}{2}) ~\\ \sin(\frac{\theta}{2}) & \cos(\frac{\theta}{2}) \\ \end{vmatrix}$

Z Rotation
RZ($\theta$)
1

$\forall \theta \in\rm I\!R$:

$\begin{vmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \\ \end{vmatrix}$

Controlled NOT
CNOT
2
$\begin{vmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ 0 & 0 & 1 & 0 \\ \end{vmatrix}$
SWAP
SWAP
2
$\begin{vmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{vmatrix}$
iSWAP
ISWAP
2
$\begin{vmatrix} 1 & 0 & 0 & 0 \\ 0 & 0 & i & 0 \\ 0 & i & 0 & 0 \\ 0 & 0 & 0 & 1 \\ \end{vmatrix}$
$\sqrt{\text{SWAP}}$
SQRTSWAP
2
$\begin{vmatrix} 1 & 0 & 0 & 0 \\ 0 & \frac{1}{2}(1 + i) & \frac{1}{2}(1 - i) & 0 \\ 0 & \frac{1}{2}(1 - i) & \frac{1}{2}(1 + i) & 0 \\ 0 & 0 & 0 & 1 \\ \end{vmatrix}$
Toffoli
CCNOT
3
$\begin{vmatrix} 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 & 1 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ \end{vmatrix}$

Short example¶

Here is a short example to illustrate the creation of a quantum program with all those gates:

In [1]:
from qat.lang.AQASM import Program, H, X, Y, Z, I, PH, S, T, RX, RY, RZ, CNOT, ISWAP, SQRTSWAP, CCNOT, SWAP

p = Program()
reg = p.qalloc(3)

p.apply(H, reg[0])
p.apply(X, reg[0])
p.apply(Y, reg[2])
p.apply(Z, reg[1])
p.apply(I, reg[1])
p.apply(S, reg[0])
p.apply(T, reg[0])
p.apply(PH(0.3), reg[0])
p.apply(RX(-0.3), reg[0])
p.apply(RY(0.6), reg[1])
p.apply(RZ(0.3), reg[0])
p.apply(CNOT, reg[0:2])
p.apply(SWAP, reg[0], reg[2])
p.apply(ISWAP, reg[1:3])
p.apply(SQRTSWAP, reg[0:2])
p.apply(CCNOT, reg)

circuit = p.to_circ()

circuit.display()
No description has been provided for this image

To learn more about how to write a quantum program with the Python AQASM library, check out this basic tutorial or this advanced tutorial

In [ ]: