cirq.BaseDensePauliString

class cirq.BaseDensePauliString(pauli_mask: Union[Iterable[cirq.PAULI_GATE_LIKE], numpy.ndarray], *, coefficient: Union[sympy.core.basic.Basic, int, float, complex] = 1)[source]

Parent class for DensePauliString and MutableDensePauliString.

__init__(pauli_mask: Union[Iterable[cirq.PAULI_GATE_LIKE], numpy.ndarray], *, coefficient: Union[sympy.core.basic.Basic, int, float, complex] = 1)[source]

Initializes a new dense pauli string.

Parameters
  • pauli_mask

    A specification of the Pauli gates to use. This argument can be a string like “IXYYZ”, or a numeric list like [0, 1, 3, 2] with I=0, X=1, Y=2, Z=3=X|Y.

    The internal representation is a 1-dimensional uint8 numpy array containing numeric values. If such a numpy array is given, and the pauli string is mutable, the argument will be used directly instead of being copied.

  • coefficient – A complex number. Usually +1, -1, 1j, or -1j but other values are supported.

Examples

>>> print(cirq.DensePauliString('XXIY'))
+XXIY
>>> print(cirq.MutableDensePauliString('IZII', coefficient=-1))
-IZII (mutable)
>>> print(cirq.DensePauliString([0, 1, 2, 3],
...                             coefficient=sympy.Symbol('t')))
t*IXYZ