# How to reset classical register on QISKit

I want to do a feedforward on a quantum circuit using the simulator of Qiskit.

For example, measure qubit_1 to bit 1 and do some operator on qubit_2 if the result of measuring qubit_1 is 0 and if the result is 0, then another operator. Then measure qubit 3 and do some operator on qubit_4 if the result of measuring qubit_3 is 1.

so far I know that I could use

QuantumCurcuit.operator(Quantumregister[index]).c_if(classicalRegister, value)


But the condition of c_if is depended on all value of all bit of classical register. I want to do feedforward depend on an individual bit just 0 or 1.

I think it is not the right way to solve the issue by adding another addition qubit to be $$|0\rangle$$ and project it on the classical bit. Just to reset that bit to 0 again this way.

So is there any way to reset the classical register?

The c_if in Qiskit only operates on a full classical register, following the OpenQASM spec. If you would like to condition on individual bits, you have to create a new ClassicalRegister for each bit. Then you can condition on each bit separately.

• I think it would be a problem when I have to plot the circuit. but yes, this is one of the solutions. Jul 15 '19 at 12:06

You dont have to reset classical registers they store the current measurment result of the quantum bits. I.e. the value of the classical register is not the matter what it matter is that the value they hold after the measurment.

• But I need a value of the classical register to do a feed-forward. The first feed-forward is not gonna be a problem but the second one is, the conditional value will grow exponentially. What I want is to reset all of the classical register and use just one condition per feed-forward. Jul 15 '19 at 12:11
• do you want to apply some gate on some qubit based on the value of the classical register?
– Aman
Jul 15 '19 at 13:58
• Yes, that is a reason why I use c_if to do this job. Jul 15 '19 at 14:39
• Then you need another quantum bit to hold the value of classical register as a black box and apply X gate on it if the value of the classical register is 1.
– Aman
Jul 15 '19 at 17:50