mindquantum.core.gates.XGate
- class mindquantum.core.gates.XGate[source]
Pauli-X gate.
Pauli X gate with matrix as:
\[\begin{split}{\rm X}=\begin{pmatrix}0&1\\1&0\end{pmatrix}\end{split}\]For simplicity, we define
X
as a instance ofXGate()
. For more redefine, please refer to the functional table below.Note
For simplicity, you can do power operator on pauli gate (only works for pauli gate at this time). The rule is set below as:
\[X^\theta = RX(\theta\pi)\]Examples
>>> from mindquantum.core.gates import X >>> x1 = X.on(0) >>> cnot = X.on(0, 1) >>> print(x1) X(0) >>> print(cnot) X(0 <-: 1) >>> x1.matrix() array([[0, 1], [1, 0]]) >>> x1**2 RX(2π) >>> (x1**'a').coeff {'a': 3.141592653589793}, const: 0.0 >>> (x1**{'a' : 2}).coeff {'a': 6.283185307179586}, const: 0.0