Fixe matrices
This commit is contained in:
parent
735cdba138
commit
88f1123114
1 changed files with 60 additions and 24 deletions
84
docs/Gate.md
84
docs/Gate.md
|
|
@ -7,90 +7,117 @@ Here is the list of all the main gates in quantum algorithm available in the lib
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
\frac {1} {\sqrt 2} & \frac {1} {\sqrt 2}\\
|
\frac {1} {\sqrt 2} & \frac {1} {\sqrt 2}\\
|
||||||
\frac {1} {\sqrt 2} & -\frac {1} {\sqrt 2}
|
\frac {1} {\sqrt 2} & -\frac {1} {\sqrt 2}
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## X(q: QuBit) -> None
|
## X(q: QuBit) -> None
|
||||||
`Pauli-X gate` or `NOT gate`. Inplementes a rotation aroud the x-axis of $\pi$ radians.
|
`Pauli-X gate` or `NOT gate`. Inplementes a rotation aroud the x-axis of $\pi$ radians.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
0 & 1\\
|
0 & 1\\
|
||||||
1 & 0
|
1 & 0
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## Y(q: QuBit) -> None
|
## Y(q: QuBit) -> None
|
||||||
`Pauli-Y gate`. Inplementes a rotation aroud the y-axis of $\pi$ radians.
|
`Pauli-Y gate`. Inplementes a rotation aroud the y-axis of $\pi$ radians.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
0 & -i\\
|
0 & -i\\
|
||||||
i & 0
|
i & 0
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## Z(q: QuBit) -> None
|
## Z(q: QuBit) -> None
|
||||||
`Pauli-Z gate`. Inplementes a rotation aroud z-axis of $\pi$ radians.
|
`Pauli-Z gate`. Inplementes a rotation aroud z-axis of $\pi$ radians.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0\\
|
1 & 0\\
|
||||||
0 & -1
|
0 & -1
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## S(q: QuBit) -> None
|
## S(q: QuBit) -> None
|
||||||
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0\\
|
1 & 0\\
|
||||||
0 & i
|
0 & i
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## T(q: QuBit) -> None
|
## T(q: QuBit) -> None
|
||||||
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0\\
|
1 & 0\\
|
||||||
0 & e^{i\frac\pi4}
|
0 & e^{i\frac\pi4}
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## Rx(q: QuBit, phi: float) -> None
|
## Rx(q: QuBit, phi: float) -> None
|
||||||
`NOT gate`. Inplementes a rotation aroud x-axis of $\phi$ radians.
|
`NOT gate`. Inplementes a rotation aroud x-axis of $\phi$ radians.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
\cos(\frac\phi2) & -\sin(\frac\phi2)\\
|
\cos(\frac\phi2) & -\sin(\frac\phi2)\\
|
||||||
\sin(\frac\phi2) & \cos(\frac\phi2)
|
\sin(\frac\phi2) & \cos(\frac\phi2)
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## Ry(q: QuBit, phi: float) -> None
|
## Ry(q: QuBit, phi: float) -> None
|
||||||
`NOT gate`. Inplementes a rotation aroud y-axis of $\pi$ radians.
|
`NOT gate`. Inplementes a rotation aroud y-axis of $\pi$ radians.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
e^{-i\frac\phi2} & 0\\
|
e^{-i\frac\phi2} & 0\\
|
||||||
0 & e^{i\frac\phi2}
|
0 & e^{i\frac\phi2}
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## R1(q: QuBit, phi: float) -> None
|
## R1(q: QuBit, phi: float) -> None
|
||||||
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
||||||
|
|
||||||
- q: the qubit manipulated by the gate. This function is in-place.
|
- q: the qubit manipulated by the gate. This function is in-place.
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0\\
|
1 & 0\\
|
||||||
0 & e^{i\frac\phi2}
|
0 & e^{i\frac\phi2}
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## CNOT(q: MuBit, n1: int, n2: int) -> None
|
## CNOT(q: MuBit, n1: int, n2: int) -> None
|
||||||
`X-controlled gate`. Invert the state |0> and |1> of the QuiBit in n2 if the state of the QuBit in n1 is 1.
|
`X-controlled gate`. Invert the state |0> and |1> of the QuiBit in n2 if the state of the QuBit in n1 is 1.
|
||||||
|
|
@ -99,12 +126,15 @@ e^{-i\frac\phi2} & 0\\
|
||||||
- n1: the first QuBit to manipualte.
|
- n1: the first QuBit to manipualte.
|
||||||
- n2: the second QuBit to manipulate
|
- n2: the second QuBit to manipulate
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0 & 0 & 0\\
|
1 & 0 & 0 & 0\\
|
||||||
0 & 1 & 0 & 0\\
|
0 & 1 & 0 & 0\\
|
||||||
0 & 0 & 0 & 1\\
|
0 & 0 & 0 & 1\\
|
||||||
0 & 0 & 1 & 0
|
0 & 0 & 1 & 0
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## SWAP(q: MuBit, n1: int, n2: int) -> None
|
## SWAP(q: MuBit, n1: int, n2: int) -> None
|
||||||
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
`NOT gate`. Invert the state |0> and |1> of the QuiBit q.
|
||||||
|
|
@ -113,12 +143,15 @@ e^{-i\frac\phi2} & 0\\
|
||||||
- n1: the first QuBit to manipualte.
|
- n1: the first QuBit to manipualte.
|
||||||
- n2: the second QuBit to manipulate
|
- n2: the second QuBit to manipulate
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0 & 0 & 0\\
|
1 & 0 & 0 & 0\\
|
||||||
0 & 0 & 1 & 0\\
|
0 & 0 & 1 & 0\\
|
||||||
0 & 1 & 0 & 0\\
|
0 & 1 & 0 & 0\\
|
||||||
0 & 0 & 0 & 1
|
0 & 0 & 0 & 1
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
||||||
## Cu(q: MuBit, u: list[list[float]], n1: int, n2: int) -> None
|
## Cu(q: MuBit, u: list[list[float]], n1: int, n2: int) -> None
|
||||||
`controlled-u gate`. Applies the gate u to the QuBit in n2 if the Qubit in n1 is 1.
|
`controlled-u gate`. Applies the gate u to the QuBit in n2 if the Qubit in n1 is 1.
|
||||||
|
|
@ -128,9 +161,12 @@ e^{-i\frac\phi2} & 0\\
|
||||||
- n1: the first QuBit to manipualte.
|
- n1: the first QuBit to manipualte.
|
||||||
- n2: the second QuBit to manipulate
|
- n2: the second QuBit to manipulate
|
||||||
|
|
||||||
- matrix: $\begin{pmatrix}
|
- matrix:
|
||||||
|
```math
|
||||||
|
\begin{pmatrix}
|
||||||
1 & 0 & 0 & 0\\
|
1 & 0 & 0 & 0\\
|
||||||
0 & 1 & 0 & 0\\
|
0 & 1 & 0 & 0\\
|
||||||
0 & 0 & u_{00} & u_{01}\\
|
0 & 0 & u_{00} & u_{01}\\
|
||||||
0 & 0 & u_{10} & u_{11}
|
0 & 0 & u_{10} & u_{11}
|
||||||
\end{pmatrix}$
|
\end{pmatrix}
|
||||||
|
```
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue