cirq.MeasurementGate

class cirq.MeasurementGate(num_qubits: int, key: str = '', invert_mask: Tuple[bool, ...] = ())[source]

A gate that measures qubits in the computational basis.

The measurement gate contains a key that is used to identify results
of measurements.
__init__(num_qubits: int, key: str = '', invert_mask: Tuple[bool, ...] = ()) → None[source]
Parameters:
  • num_qubits – The number of qubits to act upon.
  • key – The string key of the measurement.
  • invert_mask – A list of values indicating whether the corresponding qubits should be flipped. The list’s length must not be longer than the number of qubits, but it is permitted to be shorter. Qubits with indices past the end of the mask are not flipped.
Raises:

ValueError if the length of invert_mask is greater than num_qubits.

Methods

controlled_by(*control_qubits) Returns a controlled version of this gate.
num_qubits() The number of qubits this gate acts on.
on(*qubits) Returns an application of this gate to the given qubits.
validate_args(qubits) Checks if this gate can be applied to the given qubits.
with_bits_flipped(*bit_positions) Toggles whether or not the measurement inverts various outputs.
wrap_in_linear_combination(coefficient, …)