# 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

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


Methods

 controlled([num_controls, control_values, …]) Returns a controlled version of this gate. If no arguments are copy([coefficient, pauli_mask]) Returns a copy with possibly modified contents. eye(length) Creates a dense pauli string containing only identity gates. A cirq.DensePauliString with the same contents. A cirq.MutableDensePauliString with the same contents. The number of qubits this gate acts on. on(*qubits) Returns an application of this gate to the given qubits. one_hot(*, index, length, pauli) Creates a dense pauli string with only one non-identity Pauli. sparse([qubits]) A cirq.PauliString version of this dense pauli string. tensor_product(other) Concatenates dense pauli strings and multiplies their coefficients. validate_args(qubits) Checks if this gate can be applied to the given qubits. wrap_in_linear_combination([coefficient])

Attributes