INNER CODE UNIT · C++

k1

aromanro/QCSim · QCSim/DensityMatrixTests.cpp:532

        const Eigen::MatrixXcd k1 = std::sqrt(p) * cnot.getRawOperatorMatrix();
        const Eigen::MatrixXcd fullK0 = DM_EmbedOperator(k0, {0, 2}, 3);
        const Eigen::MatrixXcd fullK1 = DM_EmbedOperator(k1, {0, 2}, 3);
        const Eigen::MatrixXcd expected = fullK0 * before * fullK0.adjoint() + fullK1 * before * fullK1.adjoint();

        dm.ApplyChannel({k0, k1}, 0, 2);
        if ((dm.getDensityMatrix() - expected).norm() > 1E-10 ||
            !approxEqual(dm.Trace(), std::complex<double>(1., 0.), 1E-10) || !dm.IsHermitian(1E-10))
        {
            std::cout << "Generic non-adjacent two-qubit Kraus evolution does not match the explicit matrix result"
                      << std::endl;
            return false;
        }
    }

    std::cout << "Success" << std::endl;
    return true;
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…