Пример #1
0
 def test_concurrence_equivalence(self):
     """Test concurrence is same for equivalent inputs"""
     for alpha, beta in [(0, 0), (0, 0.25), (0.25, 0), (0.33, 0.33),
                         (0.5, 0.5), (0.75, 0.25), (0, 0.75)]:
         psi = Statevector(
             [alpha, beta, 0, 1j * np.sqrt(1 - alpha**2 - beta**2)])
         rho = DensityMatrix(psi)
         self.assertAlmostEqual(concurrence(psi), concurrence(rho))
Пример #2
0
 def test_concurrence_density_matrix(self):
     """Test concurrence function on density matrix inputs"""
     # Density matrix input
     rho1 = DensityMatrix([[0.5, 0, 0, 0.5], [0, 0, 0, 0], [0, 0, 0, 0], [0.5, 0, 0, 0.5]])
     rho2 = DensityMatrix([[0, 0, 0, 0], [0, 0.5, -0.5j, 0], [0, 0.5j, 0.5, 0], [0, 0, 0, 0]])
     self.assertAlmostEqual(concurrence(rho1), 1)
     self.assertAlmostEqual(concurrence(rho2), 1)
     self.assertAlmostEqual(concurrence(0.5 * rho1 + 0.5 * rho2), 0)
     self.assertAlmostEqual(concurrence(0.75 * rho1 + 0.25 * rho2), 0.5)
     # List input
     rho = [[0.5, 0.5, 0, 0], [0.5, 0.5, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]]
     self.assertEqual(concurrence(rho), 0)
     # Array input
     rho = np.diag([0.25, 0.25, 0.25, 0.25])
     self.assertEqual(concurrence(rho), 0)
Пример #3
0
 def test_concurrence_statevector(self):
     """Test concurrence function on statevector inputs"""
     # Statevector input
     psi = Statevector([0.70710678118654746, 0, 0, -0.70710678118654746j])
     self.assertAlmostEqual(concurrence(psi), 1)
     # List input
     psi = [1, 0, 0, 0]
     self.assertAlmostEqual(concurrence(psi), 0)
     # Array input
     psi = np.array([0.5, 0.5, 0.5, 0.5])
     self.assertAlmostEqual(concurrence(psi), 0)
     # Larger than 2 qubit input
     psi_ls = [0.70710678118654746] + (14 * [0]) + [0.70710678118654746j]
     psi = Statevector(psi_ls, dims=(2, 8))
     self.assertAlmostEqual(concurrence(psi), 1)
     psi = Statevector(psi_ls, dims=(4, 4))
     self.assertAlmostEqual(concurrence(psi), 1)
     psi = Statevector(psi_ls, dims=(8, 2))
     self.assertAlmostEqual(concurrence(psi), 1)