diff --git a/src/qunit.cpp b/src/qunit.cpp index e9977f086..caf036534 100644 --- a/src/qunit.cpp +++ b/src/qunit.cpp @@ -4033,9 +4033,9 @@ void QUnit::ApplyBuffer(PhaseShardPtr phaseShard, bitLenInt control, bitLenInt t const real1_f angleFidel2 = angleFrac(polarTop); if (!pState) { Phase(polarTop, ONE_CMPLX, t); - logFidelity += angleFidel2 * log(ONE_R1_F - pHi); - } else { logFidelity += angleFidel2 * log(pLo); + } else { + logFidelity += angleFidel2 * log(ONE_R1_F - pHi); } if (logFidelity <= FIDELITY_MIN) { throw std::runtime_error("QUnit fidelity is effectively 0!");