In some quantum algorithms, the output of the quanutm circuit is probabilistic. For example. the measurement outcome (once) for a specific qubit "0" indicates success, which means that the resulting state is what we desired. Therefore, we can first measure that special qubit for once, if the outcome is "0", then we measure the rest, othervise, we will not record this time. Can this be done in Qiskit?

I tried to solve this in another way. I don't care the qubit, after the measurement is finished, the indicater and the working system will be a joint state $\rho_{is}$, where i and s represents the indicater and system. Then we can project this state as: $$\rho_s=P\rho_{is}P^{\dagger}$$ with $P=|0\rangle \langle 0|\otimes I_s$ the projector operator. But when I put this into a function called "state_fidelity" with one other density matrix, it is error with information that the input is not a valid. Is there any points that I was wrong?

Thanks for help!


1 Answer 1


I believe you have a function that allows you to do that, check this documentation to see how this works exactly.

If you want to see an example on how to use it, you can check the step 4 of the second part of this tutorial of Qiskit, the quantum teleportation, where they apply gates regarding the measured values.

Hope this works! :)

  • 1
    $\begingroup$ Thanks a lot for your reply! I have noticed that "c_if" function before, but I executed the circuit before that function, therefore it doesn't work well. Now this is finished. Thank you again! $\endgroup$
    – 刘环宇
    Aug 25, 2020 at 1:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.