Pauli¶
-
class
Pauli
(data=None, x=None, *, z=None, label=None)[source]¶ Bases:
qiskit.quantum_info.operators.symplectic.base_pauli.BasePauli
N-qubit Pauli operator.
This class represents an operator \(P\) from the full \(n\)-qubit Pauli group
\[P = (-i)^{q} P_{n-1} \otimes ... \otimes P_{0}\]where \(q\in \mathbb{Z}_4\) and \(P_i \in \{I, X, Y, Z\}\) are single-qubit Pauli matrices:
\[\begin{split}I = \begin{pmatrix} 1 & 0 \\ 0 & 1 \end{pmatrix}, X = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix}, Y = \begin{pmatrix} 0 & -i \\ i & 0 \end{pmatrix}, Z = \begin{pmatrix} 1 & 0 \\ 0 & -1 \end{pmatrix}.\end{split}\]Initialization
A Pauli object can be initialized in several ways:
Pauli(obj)
where
obj
is a Pauli string,Pauli
orScalarOp
operator, or a Pauli gate orQuantumCircuit
containing only Pauli gates.Pauli((z, x, phase))
where
z
andx
are booleannumpy.ndarrays
andphase
is an integer in[0, 1, 2, 3]
.Pauli((z, x))
equivalent to
Pauli((z, x, 0))
with trivial phase.
String representation
An \(n\)-qubit Pauli may be represented by a string consisting of \(n\) characters from
['I', 'X', 'Y', 'Z']
, and optionally phase coefficient in \(['', '-i', '-', 'i']\). For example:XYZ
or'-iZIZ'
.In the string representation qubit-0 corresponds to the right-most Pauli character, and qubit-\((n-1)\) to the left-most Pauli character. For example
'XYZ'
represents \(X\otimes Y \otimes Z\) with'Z'
on qubit-0,'Y'
on qubit-1, and'X'
on qubit-3.The string representation can be converted to a
Pauli
using the class initialization (Pauli('-iXYZ')
). APauli
object can be converted back to the string representation using theto_label()
method orstr(pauli)
.Note
Using
str
to convert aPauli
to a string will truncate the returned string for large numbers of qubits whileto_label()
will return the full string with no truncation. The default truncation length is 50 characters. The default value can be changed by setting the class __truncate__ attribute to an integer value. If set to0
no truncation will be performed.Array Representation
The internal data structure of an \(n\)-qubit Pauli is two length-\(n\) boolean vectors \(z \in \mathbb{Z}_2^N\), \(x \in \mathbb{Z}_2^N\), and an integer \(q \in \mathbb{Z}_4\) defining the Pauli operator
\[P &= (-i)^{q + z\cdot x} Z^z \cdot X^x.\]The \(k\) and \(x\) arrays
\[\begin{split}P &= P_{n-1} \otimes ... \otimes P_{0} \\ P_k &= (-i)^{z[k] * x[k]} Z^{z[k]}\cdot X^{x[k]}\end{split}\]where
z[k] = P.z[k]
,x[k] = P.x[k]
respectively.The \(z\) and \(x\) arrays can be accessed and updated using the
z
andx
properties respectively. The phase integer \(q\) can be accessed and updated using thephase
property.Matrix Operator Representation
Pauli’s can be converted to \((2^n, 2^n)\)
Operator
using theto_operator()
method, or to a dense or sparse complex matrix using theto_matrix()
method.Data Access
The individual qubit Paulis can be accessed and updated using the
[]
operator which accepts integer, lists, or slices for selecting subsets of Paulis. Note that selecting subsets of Pauli’s will discard the phase of the current Pauli.For example
Initialize the Pauli.
When using the symplectic array input data both z and x arguments must be provided, however the first (z) argument can be used alone for string label, Pauli operator, or ScalarOp input data.
- Parameters
data (str or tuple or Pauli or ScalarOp) – input data for Pauli. If input is a tuple it must be of the form
(z, x)
or (z, x, phase)`` wherez
andx
are boolean Numpy arrays, and phase is an integer from Z_4. If input is a string, it must be a concatenation of a phase and a Pauli string (e.g. ‘XYZ’, ‘-iZIZ’) where a phase string is a combination of at most three characters from [‘+’, ‘-‘, ‘’], [‘1’, ‘’], and [‘i’, ‘j’, ‘’] in this order, e.g. ‘’, ‘-1j’ while a Pauli string is 1 or more characters of ‘I’, ‘X’, ‘Y’ or ‘Z’, e.g. ‘Z’, ‘XIYY’.x (np.ndarray) – DEPRECATED, symplectic x vector.
z (np.ndarray) – DEPRECATED, symplectic z vector.
label (str) – DEPRECATED, string label.
- Raises
QiskitError – if input array is invalid shape.
Methods
Return the adjoint of the Operator.
Return True if other Pauli anticommutes with self.
DEPRECATED: Append pauli at the end.
Return True if the Pauli commutes with other.
Return the operator composition with another Pauli.
Return the conjugate of each Pauli in the list.
Make a deep copy of current operator.
Return a Pauli with qubits deleted.
DEPRECATED: Delete pauli at the indices.
Return the right multiplied operator self * other.
Return True if Pauli’s are equivalent up to group phase.
Heisenberg picture evolution of a Pauli by a Clifford.
Return the reverse-order tensor product with another Pauli.
DEPRECATED: Construct a Pauli from a string label.
Return tuple of input dimension for specified subsystems.
Insert a Pauli at specific qubit value.
DEPRECATED: Insert or append pauli to the targeted indices.
Return the inverse of the Pauli.
DEPRECATED: Kronecker product of two paulis.
Return tuple of output dimension for specified subsystems.
DEPRECATED: Generate single qubit pauli at index with pauli_label with length num_qubits.
Return the compose of a operator with itself n times.
DEPRECATED: Return a random Pauli on number of qubits.
Return a shallow copy with reshaped input and output subsystem dimensions.
Set the max number of Pauli characters to display before truncation/
DEPRECATED: Multiply two Paulis and track the phase.
Return the tensor product with another Pauli.
Convert to Pauli circuit instruction.
Convert a Pauli to a string label.
Convert to a Numpy array or sparse CSR matrix.
DEPRECATED Convert Pauli to a sparse matrix representation (CSR format).
Return the transpose of each Pauli in the list.
DEPRECATED: Update partial or entire x.
DEPRECATED: Update partial or entire z.
Attributes
-
dim
¶ Return tuple (input_shape, output_shape).
-
num_qubits
¶ Return the number of qubits if a N-qubit operator or None otherwise.
-
phase
¶ Return the group phase exponent for the Pauli.
-
qargs
¶ Return the qargs for the operator.
-
settings
¶ Return settings.
- Return type
Dict
-
x
¶ The x vector for the Pauli.
-
z
¶ The z vector for the Pauli.