INNER CODE UNIT · C++
expected
aromanro/QCSim · QCSim/DensityMatrixTests.cpp:515
const Eigen::MatrixXcd expected = fullK0 * before * fullK0.adjoint() + fullK1 * before * fullK1.adjoint();
dm.ApplyChannel({k0, k1}, 1);
if ((dm.getDensityMatrix() - expected).norm() > 1E-10)
{
std::cout << "Generic one-qubit Kraus evolution does not match the explicit matrix result" << std::endl;
return false;
}
}
// A correlated channel on non-adjacent qubits zero and two.
{
QC::DensityMatrix<> dm(3);
const Eigen::MatrixXcd before = DM_DeterministicMixedState(3);
dm.setDensityMatrix(before);
QC::Gates::CNOTGate<> cnot;
constexpr double p = 0.37;
const Eigen::MatrixXcd k0 = std::sqrt(1. - p) * Eigen::MatrixXcd::Identity(4, 4);
const Eigen::MatrixXcd k1 = std::sqrt(p) * cnot.getRawOperatorMatrix();