- class mentpy.PauliOp
Class for representing Pauli operators as matrices and strings.
- Parameters:¶
Examples¶
Create a Pauli operator from a matrix
In [1]: op = mp.PauliOp(np.array([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])) In [2]: print(op) XI IX IZ ZI
Create a Pauli operator from a string
In [3]: op = mp.PauliOp('XIZ;ZII;IIZ;IZI') In [4]: print(op) XIZ ZII IIZ IZI
Create a Pauli operator from a list of strings
In [5]: op = mp.PauliOp(['XIZ', 'ZII', 'IIZ', 'IZI']) In [6]: print(op) XIZ ZII IIZ IZI
Constructors¶
String representation¶
- __repr__()
Return repr(self).
Special methods¶
- __getitem__(key)
- __hash__()
Return hash(self).
Methods¶
- append(other)
Appends a Pauli operator to the end of another Pauli operator.
- commutator(other) PauliOp
Returns the commutator of two Pauli operators.
- get_subset(indices)
Returns a subset of the Pauli operator.
- symplectic_prod(other)
Returns the symplectic product of two Pauli operators.
Properties¶
- property number_of_qubits
Returns the number of qubits in the Pauli operator.