quairkit.operator.gate.single_qubit_gate¶
The source file of the classes for single-qubit gates.
-
class quairkit.operator.gate.single_qubit_gate.H(qubits_idx=
None
)¶ A collection of single-qubit Hadamard gates.
The matrix form of such a gate is:
\[\begin{split}H = \frac{1}{\sqrt{2}} \begin{bmatrix} 1&1\\ 1&-1 \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.S(qubits_idx=
None
)¶ A collection of single-qubit S gates.
The matrix form of such a gate is:
\[\begin{split}S = \begin{bmatrix} 1&0\\ 0&i \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.Sdg(qubits_idx=
None
)¶ A collection of single-qubit S dagger (S inverse) gates.
The matrix form of such a gate is:
\[\begin{split}S^\dagger = \begin{bmatrix} 1&0\\ 0&-i \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.T(qubits_idx=
None
)¶ A collection of single-qubit T gates.
The matrix form of such a gate is:
\[\begin{split}T = \begin{bmatrix} 1&0\\ 0&e^\frac{i\pi}{4} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.Tdg(qubits_idx=
None
)¶ A collection of single-qubit T dagger (T inverse) gates.
The matrix form of such a gate is:
\[\begin{split}T^\dagger = \begin{bmatrix} 1&0\\ 0&e^{-\frac{i\pi}{4}} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.X(qubits_idx=
None
)¶ A collection of single-qubit X gates.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} 0 & 1 \\ 1 & 0 \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.Y(qubits_idx=
None
)¶ A collection of single-qubit Y gates.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} 0 & -i \\ i & 0 \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.Z(qubits_idx=
None
)¶ A collection of single-qubit Z gates.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} 1 & 0 \\ 0 & -1 \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.P(qubits_idx=
None
, param=None
, param_sharing=False
)¶ A collection of single-qubit P gates.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} 1 & 0 \\ 0 & e^{i\theta} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.RX(qubits_idx=
None
, param=None
, param_sharing=False
)¶ A collection of single-qubit rotation gates about the x-axis.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} \cos\frac{\theta}{2} & -i\sin\frac{\theta}{2} \\ -i\sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.RY(qubits_idx=
None
, param=None
, param_sharing=False
)¶ A collection of single-qubit rotation gates about the y-axis.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} \cos\frac{\theta}{2} & -\sin\frac{\theta}{2} \\ \sin\frac{\theta}{2} & \cos\frac{\theta}{2} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.RZ(qubits_idx=
None
, param=None
, param_sharing=False
)¶ A collection of single-qubit rotation gates about the z-axis.
The matrix form of such a gate is:
\[\begin{split}\begin{bmatrix} e^{-i\frac{\theta}{2}} & 0 \\ 0 & e^{i\frac{\theta}{2}} \end{bmatrix}\end{split}\]
-
class quairkit.operator.gate.single_qubit_gate.U3(qubits_idx=
None
, param=None
, param_sharing=False
)¶ A collection of single-qubit rotation gates.
The matrix form of such a gate is:
\[\begin{split}\begin{align} U3(\theta, \phi, \lambda) = \begin{bmatrix} \cos\frac\theta2&-e^{i\lambda}\sin\frac\theta2\\ e^{i\phi}\sin\frac\theta2&e^{i(\phi+\lambda)}\cos\frac\theta2 \end{bmatrix} \end{align}\end{split}\]- Parameters:¶
- qubits_idx : Iterable | int | str | None¶
Indices of the qubits on which the gates are applied. Defaults to the first qubit.
- param : Tensor | Iterable[float] | None¶
Parameters of the gates. Defaults to
None
.- param_sharing : bool | None¶
Whether gates in the same layer share a parameter. Defaults to
False
.
- Raises:¶
ValueError – The
param
must betorch.Tensor
orfloat
.