Example #1
0
 def test_monotonicity(self, dimension):
     """
     Check monotonicity w.r.t. tensor product, see. Eq. (45) in
     arXiv:1611.03449v2:
         hellinger_dist(rhoA & rhoB, sigmaA & sigmaB)
         >= hellinger_dist(rhoA, sigmaA)
     with equality iff sigmaB = rhoB where '&' is the tensor product.
     """
     tol = 1e-5
     rhoA, rhoB, sigmaA, sigmaB = [rand_dm(dimension) for _ in [None] * 4]
     rho = tensor(rhoA, rhoB)
     rho_sim = tensor(rhoA, sigmaB)
     sigma = tensor(sigmaA, sigmaB)
     dist = hellinger_dist(rhoA, sigmaA)
     assert hellinger_dist(rho, sigma) + tol > dist
     assert hellinger_dist(rho_sim, sigma) == pytest.approx(dist, abs=tol)
Example #2
0
 def test_orthogonal(self, left_dm, right_dm, dimension):
     left = basis(dimension, 0)
     right = basis(dimension, dimension // 2)
     if left_dm:
         left = left.proj()
     if right_dm:
         right = right.proj()
     expected = np.sqrt(2)
     assert hellinger_dist(left, right) == pytest.approx(expected, abs=1e-6)
Example #3
0
 def test_inequality_hellinger_dist_to_bures_dist(self, left, right):
     tol = 1e-7
     hellinger = hellinger_dist(left, right)
     bures = bures_dist(left, right)
     assert bures <= hellinger + tol
Example #4
0
 def test_known_cases_pure_states(self, dimension):
     left = rand_ket(dimension)
     right = rand_ket(dimension)
     expected = np.sqrt(2 * (1 - np.abs(left.overlap(right))**2))
     assert hellinger_dist(left, right) == pytest.approx(expected, abs=1e-7)
Example #5
0
 def test_state_with_itself(self, state):
     assert hellinger_dist(state, state) == pytest.approx(0, abs=1e-6)