cirq.DensePauliString

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

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

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.

frozen()

A cirq.DensePauliString with the same contents.

mutable_copy()

A cirq.MutableDensePauliString with the same contents.

num_qubits()

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

I_VAL

X_VAL

Y_VAL

Z_VAL