def test_rand_product_state(self): a = qu.rand_product_state(3) assert a.shape[0] == 2**3 assert (a.H @ a)[0, 0].real == pytest.approx(1.0) assert qu.mutinf(a, [2, 2, 2], 0, 1) == pytest.approx(0.0) assert qu.mutinf(a, [2, 2, 2], 1, 2) == pytest.approx(0.0) assert qu.mutinf(a, [2, 2, 2], 0, 2) == pytest.approx(0.0)
def test_rand_product_state(self): a = rand_product_state(3) assert a.shape[0] == 2**3 assert_almost_equal((a.H @ a)[0, 0].real, 1.0) assert_almost_equal(mutual_information(a, [2, 2, 2], 0, 1), 0.0) assert_almost_equal(mutual_information(a, [2, 2, 2], 1, 2), 0.0) assert_almost_equal(mutual_information(a, [2, 2, 2], 0, 2), 0.0)
def test_rand_product_state(self): a = qu.rand_product_state(3) assert a.shape[0] == 2**3 assert_allclose((a.H @ a)[0, 0].real, 1.0) assert_allclose(qu.mutinf(a, [2, 2, 2], 0, 1), 0.0) assert_allclose(qu.mutinf(a, [2, 2, 2], 1, 2), 0.0) assert_allclose(qu.mutinf(a, [2, 2, 2], 0, 2), 0.0)
def test_owci(self): a = qu.qu([1, 0], qtype='op') b = qu.qu([0, 1], qtype='op') for _ in (0, 1, 2, 3): p = qu.rand_product_state(2) ci = qu.one_way_classical_information(p @ p.H, [a, b]) assert_allclose(ci, 0., atol=1e-12) for i in (0, 1, 2, 3): p = qu.bell_state(i) ci = qu.one_way_classical_information(p @ p.H, [a, b]) assert_allclose(ci, 1., atol=1e-12)
def test_norm_trace_dense(self): a = qu.qarray(np.diag([-3, 1, 7])) assert qu.norm(a, "trace") == 11 a = qu.rand_product_state(1, qtype="dop") assert_allclose(qu.norm(a, "nuc"), 1)
def test_random_product_state(self, pre_c): p = qu.rand_product_state(3) qids = qu.qid(p, dims=[2, 2, 2], inds=[0, 1, 2], precomp_func=pre_c) assert_allclose(qids(p) if pre_c else qids, [2, 2, 2])
def test_quantum_discord_sep(self): for _ in range(10): p = qu.rand_product_state(2) p = p @ p.H qd = qu.quantum_discord(p) assert_allclose(0.0, qd, atol=1e-12)
def test_mutual_information_pure(self): a = qu.bell_state(0) assert_allclose(qu.mutual_information(a), 2.) a = qu.rand_product_state(2) assert_allclose(qu.mutual_information(a), 0., atol=1e-12)
def test_norm_trace_dense(self): a = np.asmatrix(np.diag([-3, 1, 7])) assert norm(a, "trace") == 11 a = rand_product_state(1, qtype="dop") assert_allclose(norm(a, "nuc"), 1)