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,ParameterizedConditional 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
CbitExpressionthat 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]]]]¶
- 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.
- 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
selfwith replaced parameters.