From a13117f96420b1c647d096ee22a5bd015b088248 Mon Sep 17 00:00:00 2001 From: WrathfulSpatula Date: Mon, 11 Nov 2024 21:12:54 -0500 Subject: [PATCH] Debug ApplyBuffer() classical shadows --- src/qunit.cpp | 3 ++- test/benchmarks.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/qunit.cpp b/src/qunit.cpp index def4bd3f4..0d2002d81 100644 --- a/src/qunit.cpp +++ b/src/qunit.cpp @@ -4048,9 +4048,10 @@ void QUnit::ApplyBuffer(PhaseShardPtr phaseShard, bitLenInt control, bitLenInt t const real1_f pch = Prob(control); const real1_f phHi = pth > pch ? pth : pch; const real1_f phLo = pth > pch ? pch : pth; + const bool phState = abs(phHi - (ONE_R1_F / 2)) >= abs(phLo - (ONE_R1_F / 2)); const bitLenInt th = pth > pch ? control : target; - if ((2 * phHi) > ONE_R1_F) { + if (phState) { Phase(ONE_CMPLX, -ONE_CMPLX, th); logFidelity += log(phHi); } else { diff --git a/test/benchmarks.cpp b/test/benchmarks.cpp index d3cb01f4e..aa6c7c045 100644 --- a/test/benchmarks.cpp +++ b/test/benchmarks.cpp @@ -229,7 +229,7 @@ void benchmarkLoopVariable(std::function fn, bit qftReg->SetReactiveSeparate(false); } - sampleFailureCount++; + ++sampleFailureCount; } }