Skip to content

Commit

Permalink
Debug QUnit classical shadows
Browse files Browse the repository at this point in the history
  • Loading branch information
WrathfulSpatula committed Nov 12, 2024
1 parent 57432fb commit c4fc7cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/qunit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4014,20 +4014,20 @@ void QUnit::ApplyBuffer(PhaseShardPtr phaseShard, bitLenInt control, bitLenInt t
}
const real1_f pc = Prob(control);
const real1_f pt = Prob(target);
const real1_f pHi = pt > pc ? pt : pc;
const real1_f pLo = pt > pc ? pc : pt;
const bool ptHi = pt > pc;
const real1_f pHi = ptHi ? pt : pc;
const real1_f pLo = ptHi ? pc : pt;
const bool pState = abs(pHi - (ONE_R1_F / 2)) >= abs(pLo - (ONE_R1_F / 2));

logFidelity += (angleFrac(polarBottom) + angleFrac(polarTop)) * log(pState ? pHi : (ONE_R1_F - pLo));
if (logFidelity <= FIDELITY_MIN) {
throw std::runtime_error("QUnit fidelity is effectively 0!");
}

const bitLenInt t = (pState == (pt > pc)) ? control : target;
if (pState) {
Phase(ONE_CMPLX, polarBottom, t);
Phase(ONE_CMPLX, polarBottom, ptHi ? control : target);
} else {
Phase(polarTop, ONE_CMPLX, t);
Phase(ONE_CMPLX, polarTop, ptHi ? target : control);
}

if (phaseShard->isInvert) {
Expand Down

0 comments on commit c4fc7cf

Please sign in to comment.