mindquantum.core.gates.GroupedPauli
- class mindquantum.core.gates.GroupedPauli(pauli_string: str)[source]
Multi qubit pauli string gate.
Pauli string gate apply all pauli operator on the quantum state at same time, which is much faster than apply them one by one.
\[U =\otimes_i\sigma_i, \text{where } \sigma \in \{I, X, Y, Z\}\]- Parameters
pauli_string (str) – The pauli string. Each element should be in
['i', 'x', 'y', 'z', 'I', 'X', 'Y', 'Z']
.
Examples
>>> import numpy as np >>> from mindquantum.core.gates import GroupedPauli >>> from mindquantum.core.circuit import Circuit >>> circ1 = Circuit([GroupedPauli('XY').on([0, 1])]) >>> circ2 = Circuit().x(0).y(1) >>> np.allclose(circ1.matrix(), circ2.matrix()) True >>> np.allclose(circ1.matrix(), circ1[0].matrix()) True