コード例 #1
0
def test_depolarizing() -> None:
    p = 1.0 - np.exp(-1 / 20)

    chan = qf.Depolarizing(p, 0).aschannel()
    rho0 = qf.Density([[0.5, 0], [0, 0.5]])
    assert qf.densities_close(rho0, chan.evolve(rho0))

    rho0 = qf.random_density(1)
    rho1 = chan.evolve(rho0)
    pr0 = np.real(qf.purity(rho0))
    pr1 = np.real(qf.purity(rho1))
    assert pr0 > pr1

    # Test data extracted from refereneqvm
    rho2 = qf.Density([[0.43328691, 0.48979689], [0.48979689, 0.56671309]])
    rho_test = qf.Density(
        [[0.43762509 + 0.0j, 0.45794666 + 0.0j], [0.45794666 + 0.0j, 0.56237491 + 0.0j]]
    )
    assert qf.densities_close(chan.evolve(rho2), rho_test)

    ket0 = qf.random_state(1)
    qf.Depolarizing(p, 0).run(ket0)

    rho1b = qf.Depolarizing(p, 0).evolve(rho0)
    assert qf.densities_close(rho1, rho1b)
コード例 #2
0
def test_kraus_complete():
    kraus = qf.Kraus([qf.X(1)])
    assert qf.kraus_iscomplete(kraus)

    kraus = qf.Damping(0.1, 0)
    assert qf.kraus_iscomplete(kraus)

    assert qf.kraus_iscomplete(qf.Damping(0.1, 0))
    assert qf.kraus_iscomplete(qf.Dephasing(0.1, 0))
    assert qf.kraus_iscomplete(qf.Depolarizing(0.1, 0))
コード例 #3
0
def test_askraus():
    def _roundtrip(kraus):
        assert qf.kraus_iscomplete(kraus)

        chan0 = kraus.aschannel()
        kraus1 = qf.channel_to_kraus(chan0)
        assert qf.kraus_iscomplete(kraus1)

        chan1 = kraus1.aschannel()
        assert qf.channels_close(chan0, chan1)

    p = 1 - np.exp(-50 / 15000)
    _roundtrip(qf.Kraus([qf.X(1)]))
    _roundtrip(qf.Damping(p, 0))
    _roundtrip(qf.Depolarizing(0.9, 1))
コード例 #4
0
def test_stdchannels_creation():
    qf.Damping(0.1, 0).aschannel()
    qf.Depolarizing(0.1, 0).aschannel()
    qf.Dephasing(0.1, 0).aschannel()
コード例 #5
0
def test_stdkraus_creation():
    qf.Damping(0.1, 0)
    qf.Depolarizing(0.1, 0)
    qf.Dephasing(0.1, 0)