- QuantumCircuit.if_else(condition, true_body, false_body, qubits, clbits, label=None)¶
This method does not have an associated context-manager form, because it is already handled by the
if_test()method. You can use the
elsepart of that with something such as:
from qiskit.circuit import QuantumCircuit, Qubit, Clbit bits = [Qubit(), Qubit(), Clbit()] qc = QuantumCircuit(bits) qc.h(0) qc.cx(0, 1) qc.measure(0, 0) with qc.if_test((bits, 0)) as else_: qc.h(0) with else_: qc.x(0)
bool]]) – A condition to be evaluated at circuit runtime which, if true, will trigger the evaluation of
true_body. Can be specified as either a tuple of a
ClassicalRegisterto be tested for equality with a given
int, or as a tuple of a
Clbitto be compared to either a
QuantumCircuit) – The circuit body to be run if
QuantumCircuit) – The circuit to be run if
str]) – The string label of the instruction in the circuit.
CircuitError – If the provided condition references Clbits outside the enclosing circuit.
- Type renvoyé
A handle to the instruction created.