def test_x90_coherent_error_matrix(self): X90 = np.array([[1, -1j], [-1j, 1]]) / np.sqrt(2) U = x90_error_matrix(0., 0.).dot(X90) target = X90 self.assertAlmostEqual(norm(U - target), 0.0, places=10, msg="identity error matrix") U = x90_error_matrix(np.pi / 2., 0.).dot(X90) target = -1j * np.array([[0, 1], [1, 0]]) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(0., np.pi / 2.).dot(X90) target = np.array([[1., -1], [1, 1.]]) / np.sqrt(2.) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(np.pi / 2, np.pi / 2.).dot(X90) target = np.array([[0., -1], [1, 0.]]) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(0.02, -0.03) self.assertAlmostEqual(norm(U.dot(U.conj().T) - np.eye(2)), 0.0, places=10, msg="Test error matrix is unitary")
def test_x90_coherent_error_matrix(self): X90 = np.array([[1, -1j], [-1j, 1]]) / np.sqrt(2) U = x90_error_matrix(0., 0.).dot(X90) target = X90 self.assertAlmostEqual(norm(U - target), 0.0, places=10, msg="identity error matrix") U = x90_error_matrix(np.pi / 2., 0.).dot(X90) target = -1j * np.array([[0, 1], [1, 0]]) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(0., np.pi / 2.).dot(X90) target = np.array([[1., -1], [1, 1.]]) / np.sqrt(2.) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(np.pi / 2, np.pi / 2.).dot(X90) target = np.array([[0., -1], [1, 0.]]) self.assertAlmostEqual(norm(U - target), 0.0, places=10) U = x90_error_matrix(0.02, -0.03) self.assertAlmostEqual(norm(U.dot(U.conj().T) - np.eye(2)), 0.0, places=10, msg="Test error matrix is unitary")