mindquantum.core.gates.GroupedPauli

View Source On Gitee
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
get_cpp_obj()[source]

Construct cpp obj.

matrix(full=False)[source]

Matrix of this gate.

Parameters

full (bool) – Whether to get the full matrix of this gate (the gate should be acted on some qubits). Default: False.

Returns

numpy.ndarray, the matrix of this gate.