cirq.BitMaskKeyCondition

A multiqubit classical control condition with a bitmask.

Inherits From: Condition

Used in the notebooks

Used in the tutorials

The control is based on a single measurement key and allows comparing equality or inequality after taking the bitwise and with a bitmask.

  • BitMaskKeyCondition('a') -> a != 0
  • BitMaskKeyCondition('a', bitmask=13) -> (a & 13) != 0
  • BitMaskKeyCondition('a', bitmask=13, target_value=9) -> (a & 13) != 9
  • BitMaskKeyCondition('a', bitmask=13, target_value=9, equal_target=True) -> (a & 13) == 9
  • BitMaskKeyCondition.create_equal_mask('a', 13) -> (a & 13) == 13
  • BitMaskKeyCondition.create_not_equal_mask('a', 13) -> (a & 13) != 13

The bits in the bitmask have the same order as the qubits passed to cirq.measure(...). That's the most significant bit corresponds to the the first (left most) qubit.

  • key: Measurement key.
  • index: integer index (same as KeyCondition.index).
  • target_value: The value we compare with.
  • equal_target: Whether to comapre with == or !=.
  • bitmask: Optional bitmask to apply before doing the comparison.
bitmask

equal_target

index

key

keys Gets the control keys.
qasm Returns the qasm of this condition.
target_value

Methods

create_equal_mask

View source

Creates a condition that evaluates (meas & bitmask) == bitmask.

create_not_equal_mask

View source

Creates a condition that evaluates (meas & bitmask) != bitmask.

replace_key

View source

Replaces the control keys.

resolve

View source

Resolves the condition based on the measurements.

__eq__

Method generated by attrs for class BitMaskKeyCondition.

__ne__

Check equality and either forward a NotImplemented or return the result negated.