Gate package
Module contents
Contains all the standard gates that can be used in the circuit. These include:
gate module
Gate class
- class qclight.gate.gate.Gate[source]
Bases:
object
Gates are the basic building blocks of quantum circuits. They are used to manipulate the state of a quantum system and compute functions.
- I = array([[1, 0], [0, 1]])
- property matrix: ndarray
Matrix representation of the gate.
- Return type
ndarray
- matrix_of_size(size, idx=None)[source]
Returns the matrix representation of the gate in a matrix of size n x n, using the tensor product.
If idx is None, the matrix is multiplied by itself. If idx is provided, the matrix is multiplied by the identity matrix in all the positions except for idx, where the matrix is multiplied by itself.
- Parameters
size (
int
) – size of the matrixidx (
Union
[int
,list
[int
],None
], default:None
) – index of the matrix in the tensor product
- Returns
ndarray
– matrix representation of the gate in a matrix of size n x n
h_gate module
HGate class
- class qclight.gate.h_gate.HGate[source]
Bases:
Gate
Hadamard gate. It rotates a qubit and puts it in a state of superpositions.
\[\begin{split}H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1 & 1 \\ 1 & -1 \end{bmatrix}\end{split}\]- H: ndarray[Any, dtype[float64]] = array([[ 0.70710678, 0.70710678], [ 0.70710678, -0.70710678]])
- property matrix: ndarray[Any, dtype[float64]]
Matrix representation of the gate.
- Return type
ndarray
[Any
,dtype
[float64
]]
i_gate module
IGate class
- class qclight.gate.i_gate.IGate[source]
Bases:
Gate
Identity gate. It does not change the state of a qubit.
\[\begin{split}I = \begin{bmatrix} 1 & 0 \\ 0 & 1 \end{bmatrix}\end{split}\]- property matrix: ndarray[Any, dtype[float64]]
Matrix representation of the gate.
- Return type
ndarray
[Any
,dtype
[float64
]]
x_gate module
XGate class
- class qclight.gate.x_gate.XGate[source]
Bases:
Gate
Negation gate. It negates the state of a qubit.
\[\begin{split}X = \begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\end{split}\]- X: ndarray[Any, dtype[float64]] = array([[0, 1], [1, 0]])
- property matrix: ndarray[Any, dtype[float64]]
Matrix representation of the gate.
- Return type
ndarray
[Any
,dtype
[float64
]]
z_gate module
ZGate class
- class qclight.gate.z_gate.ZGate[source]
Bases:
Gate
Z gate. It rotates a qubit by \(\pi\) radians around the z-axis.
\[\begin{split}Z = \begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\end{split}\]- Z: ndarray[Any, dtype[float64]] = array([[ 1, 0], [ 0, -1]])
- property matrix: ndarray[Any, dtype[float64]]
Matrix representation of the gate.
- Return type
ndarray
[Any
,dtype
[float64
]]