conditional_operator

Define classically conditioned operators.

The state of one or more classical bits controls whether a certain operator acts on one or more target qubits.

class parityos.operators.conditional_operator.ConditionalOperator(condition: Cbit | CbitExpression, target_operator: ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]] | ControlledOperator[QubitT_co, ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]] | OperatorProduct[ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]]]])

Bases: Operator[QubitT_co], HasFrozenCBits, Parameterized

Conditional operator where the application of the target operator depends on a condition in the form of a classical boolean function. The target operator is triggered when the condition evaluates to True.

condition: CbitExpression

Condition in the form of a CbitExpression that will be applied to the classical bits.

target_operator: ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]] | ControlledOperator[QubitT_co, ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]] | OperatorProduct[ConcreteOperator[QubitT_co] | RotationOperator[QubitT_co, HermitianOperator[QubitT_co]]]]

Operator acting on target qubits if condition is True.

property name: str

Dynamically generated name for this operator.

Where applicable the name must coincide with the OpenQASM standard.

qubits: frozenset[QubitT_co]

Unordered set of qubits of target_operator.

ordered_qubits: tuple[QubitT_co, ...]

Ordered sequence of qubits of target_operator.

cbits: frozenset[Cbit]
ordered_cbits: tuple[Cbit, ...]
get_hermitian_conjugate() Self

Return the hermitian conjugate (\(\dagger\)) of this operator.

is_hermitian: bool
parameters: frozenset[Parameter]

The symbolic parameters of the target_operator.

substitute_parameters(old_to_new: Mapping[Parameter, Symbolic | complex]) Self

Substitute symbolic parameters with new symbolic expressions or numeric values.

Parameters:

old_to_new – Mapping from existing parameter symbols to new values (numeric or symbolic).

Returns:

Copy of self with replaced parameters.