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.
Attributes
coefficient
A complex coefficient or symbol.
pauli_mask
A 1-dimensional uint8 numpy array giving a specification of Pauli gates to use.
Returns a controlled version of this gate.
If no arguments are
specified, defaults to a single qubit control.
Args
num_controls
Total number of control qubits.
control_values
Which control computational basis state to apply the
sub gate. A sequence of length num_controls where each
entry is an integer (or set of integers) corresponding to the
computational basis state (or set of possible values) where that
control is enabled. When all controls are enabled, the sub gate is
applied. If unspecified, control values default to 1.
control_qid_shape
The qid shape of the controls. A tuple of the
expected dimension of each control qid. Defaults to
(2,) * num_controls. Specify this argument when using qudits.
Returns
A cirq.Gate representing self controlled by the given control values
and qubits. This is a cirq.ControlledGate in the base
implementation, but subclasses may return a different gate type.
Returns a list of operations applying the gate to all targets.
Args
*targets
The qubits to apply this gate to. For single-qubit gates
this can be provided as varargs or a combination of nested
iterables. For multi-qubit gates this must be provided as an
Iterable[Sequence[Qid]], where each sequence has num_qubits
qubits.
Returns
Operations applying this gate to the target qubits.
Raises
ValueError
If targets are not instances of Qid or Iterable[Qid].
If the gate qubit number is incompatible.
TypeError
If a single target is supplied and it is not iterable.
Creates a dense pauli string with only one non-identity Pauli.
Args
index
The index of the Pauli that is not an identity.
length
The total length of the string to create.
pauli
The pauli gate to put at the hot index. Can be set to either
a string ('X', 'Y', 'Z', 'I'), a cirq gate (cirq.X,
cirq.Y, cirq.Z, or cirq.I), or an integer (0=I, 1=X, 2=Y,
3=Z).
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-10-08 UTC."],[],[]]