INNER CODE UNIT · C++
sampled
aromanro/QCSim · QCSim/DensityMatrixTests.cpp:1016
const double sampled = static_cast<double>(ones) / nrMeasurements;
if (std::abs(sampled - expectedP1[q]) > 0.05)
{
std::cout << "Measurement statistics mismatch for qubit " << q << " with " << nrQubits
<< " qubits: " << expectedP1[q] << " (analytic) vs " << sampled << " (sampled)" << std::endl;
return false;
}
}
}
// DephaseMeasure keeps the populations but removes the coherences between the measured sectors
{
QC::DensityMatrix<> dm(1);
QC::Gates::HadamardGate<> h;
dm.ApplyGate(h, 0); // |+>: rho = 1/2 [[1,1],[1,1]]
const double p1Before = dm.GetQubitProbability(0);
dm.DephaseMeasure(0);