Pauli¶
- class Pauli(z=None, x=None, label=None)[source]¶
A simple class representing Pauli Operators.
The form is P_zx = (-i)^dot(z,x) Z^z X^x where z and x are elements of Z_2^n. That is, there are 4^n elements (no phases in this group).
For example, for 1 qubit P_00 = Z^0 X^0 = I P_01 = X P_10 = Z P_11 = -iZX = (-i) iY = Y
The overload __mul__ does not track the sign: P1*P2 = Z^(z1+z2) X^(x1+x2) but sgn_prod does __mul__ and track the phase: P1*P2 = (-i)^dot(z1+z2,x1+x2) Z^(z1+z2) X^(x1+x2) where the sums are taken modulo 2.
Pauli vectors z and x are supposed to be defined as boolean numpy arrays.
Ref. Jeroen Dehaene and Bart De Moor Clifford group, stabilizer states, and linear and quadratic operations over GF(2) Phys. Rev. A 68, 042318 – Published 20 October 2003
Make the Pauli object.
- Note that, for the qubit index:
Order of z, x vectors is q_0 … q_{n-1},
Order of pauli label is q_{n-1} … q_0
- E.g.,
z and x vectors: z = [z_0 … z_{n-1}], x = [x_0 … x_{n-1}]
a pauli is $P_{n-1} otimes … otimes P_0$
- Parameters
z (numpy.ndarray) – boolean, z vector
x (numpy.ndarray) – boolean, x vector
label (str) – pauli label
Attributes
Number of qubits.
Deprecated, use
num_qubits
instead.Getter of x.
Getter of z.
Methods
Return number of qubits.
Pauli.__mul__
(other)Multiply two Paulis.
Pauli.append_paulis
([paulis, pauli_labels])Append pauli at the end.
Pauli.delete_qubits
(indices)Delete pauli at the indices.
Pauli.from_label
(label)Take pauli string to construct pauli.
Pauli.insert_paulis
([indices, paulis, …])Insert or append pauli to the targeted indices.
Pauli.kron
(other)Kronecker product of two paulis.
Pauli.pauli_single
(num_qubits, index, …)Generate single qubit pauli at index with pauli_label with length num_qubits.
Pauli.random
(num_qubits[, seed])Return a random Pauli on number of qubits.
Pauli.sgn_prod
(p1, p2)Multiply two Paulis and track the phase.
Convert to Pauli circuit instruction.
Present the pauli labels in I, X, Y, Z format.
Convert Pauli to a matrix representation.
Convert to Operator object.
Convert Pauli to a sparse matrix representation (CSR format).
Pauli.update_x
(x[, indices])Update partial or entire x.
Pauli.update_z
(z[, indices])Update partial or entire z.