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!