3 KiB
QuBit
QuBit(alpha: complexe, beta: complexe)
- alpha: complexe value for |0>
- beta: complexe value for |1>
Attributes
-
__state: list[complexe]list of the values for the state |0> and |1>
-
__intricated: booltells if the qubit is intricated or not
Methode
-
__init__(alpha: complexe=1, beta: complexe=0) -> Noneinitiates the qubit
-
is_intricated() -> boolreturns the value of __intricated
-
get_MuBit() -> Nonereturns the MuBit in wich the QuBit is intricated. If not intricated, rerurns None
-
__str__() -> strreturns a string representation of the list of __state
-
__apply(m: Matrix) -> Nonetakes a Matrix and modifies the QuBit according the matrix
-
observe() -> list[int]forces the QuBit in a state, where the probabilities are given throught __state. Returns the new __state obtained.
Staticmethods
-
I() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0\\
0 & 1
\end{pmatrix}
-
H() -> Matrixreturns the matrix
\begin{pmatrix}
\frac {1} {\sqrt 2} & \frac {1} {\sqrt 2}\\
\frac {1} {\sqrt 2} & -\frac{1} {\sqrt 2}
\end{pmatrix}
-
X() -> Matrixreturns the matrix
\begin{pmatrix}
0 & 1\\
1 & 0
\end{pmatrix}
-
Y() -> Matrixreturns the matrix
\begin{pmatrix}
0 & -i\\
i & 0
\end{pmatrix}
-
Z() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0\\
0 & -1
\end{pmatrix}
-
S() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0\\
0 & i
\end{pmatrix}
-
T() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0\\
0 & e^{i\frac {\pi} {4}}
\end{pmatrix}
-
Rx(phi: float) -> Matrixreturns the matrix
\begin{pmatrix}
\cos(\frac \phi 2) & -i\sin(\frac \phi 2)\\
-i\sin(\frac \phi 2) & \cos(\frac \phi 2)
\end{pmatrix}
-
Ry(phi: float) -> Matrixreturns the matrix
\begin{pmatrix}
\cos(\frac \phi 2) & -\sin(\frac \phi 2)\\
\sin(\frac \phi 2) & \cos(\frac \phi 2)
\end{pmatrix}
-
Rz(phi: float) -> Matrixreturns the matrix
\begin{pmatrix}
e^{-i\frac \phi 2} & 0\\
0 & e^{i\frac \phi 2}
\end{pmatrix}
-
R1(phi: float) -> Matrixreturns the matrix
\begin{pmatrix}
1 & p\\
0 & e^{i\phi}
\end{pmatrix}
-
CNOT() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & 1 & 0 & 0\\
0 & 0 & 0 & 1\\
0 & 0 & 1 & 0
\end{pmatrix}
-
SWAP() -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & 0 & 1 & 0\\
0 & 1 & 0 & 0\\
0 & 0 & 0 & 0
\end{pmatrix}
-
Cu(u: Matrix) -> Matrixreturns the matrix
\begin{pmatrix}
1 & 0 & 0 & 0\\
0 & 1 & 0 & 0\\
0 & 0 & u_{00} & u_{01}\\
0 & 0 & u_{10} & u_{11}
\end{pmatrix}