- InstructionSet.c_if(classical, val)[código fonte]¶
Set a classical equality condition on all the instructions in this set between the
This is a setter method, not an additive one. Calling this multiple times will silently override any previously set condition on any of the contained instructions; it does not stack.
classical (Clbit | ClassicalRegister | int) – the classical resource the equality condition should be on. If this is given as an integer, it will be resolved into a
Clbitusing the same conventions as the circuit these instructions are attached to.
val (int) – the value the classical resource should be equal to.
This same instance of
InstructionSet, but now mutated to have the given equality condition.
CircuitError – if the passed classical resource is invalid, or otherwise not resolvable to a concrete resource that these instructions are permitted to access.
- Tipo de retorno
from qiskit import ClassicalRegister, QuantumRegister, QuantumCircuit qr = QuantumRegister(2) cr = ClassicalRegister(2) qc = QuantumCircuit(qr, cr) qc.h(range(2)) qc.measure(range(2), range(2)) # apply x gate if the classical register has the value 2 (10 in binary) qc.x(0).c_if(cr, 2) # apply y gate if bit 0 is set to 1 qc.y(1).c_if(0, 1) qc.draw('mpl')