def test_quad_form(self, hbar): """Test it has the correct form using quadrature operators""" H, _ = two_mode_squeezing(2, mode1=1, mode2=3, hbar=hbar) H = normal_ordered(get_quad_operator(H, hbar=hbar), hbar=hbar) expected = QuadOperator('q1 p3', 1) expected += QuadOperator('p1 q3', 1) assert H == expected
def test_two_mode_squeeze_coeff(self, hbar): """Test quadratic coefficients for S2gate""" H, _ = two_mode_squeezing(0.23, hbar=hbar) res, d = quadratic_coefficients(get_quad_operator(H, hbar)) expected = np.fliplr(np.diag([1] * 4)) assert np.allclose(res, expected) assert np.allclose(d, np.zeros([4]))
def test_two_mode_squeeze_coeff(self): """Test quadratic coefficients for S2gate""" self.logTestName() H, _ = two_mode_squeezing(0.23, hbar=self.hbar) res, d = quadratic_coefficients(get_quad_operator(H, self.hbar)) expected = np.fliplr(np.diag([1]*4)) self.assertTrue(np.allclose(res, expected)) self.assertTrue(np.allclose(d, np.zeros([4])))
def test_quad_form(self): """Test it has the correct form using quadrature operators""" self.logTestName() H, _ = two_mode_squeezing(2, mode1=1, mode2=3, hbar=self.hbar) H = normal_ordered(get_quad_operator(H, hbar=self.hbar), hbar=self.hbar) expected = QuadOperator('q1 p3', 1) expected += QuadOperator('p1 q3', 1) self.assertEqual(H, expected)
def test_two_mode_squeezing(self, hbar): """Test S2gate produces correct cov and means""" H, t = two_mode_squeezing(self.r, self.phi, hbar=hbar) resD, resV = self.H_circuit(H, t) gate = S2gate(self.r, self.phi) expD, expV = self.ref_circuit(gate) # test the covariance matrix assert np.allclose(resV, expV) # test the vector of means assert np.allclose(resD, expD)
def test_two_mode_gate(self, hbar): """Test S2gate gives correct means and cov in global mode""" H, t = two_mode_squeezing(self.r, self.phi, mode1=0, mode2=2, hbar=hbar) resD, resV = self.H_circuit(H, t) gate = S2gate(self.r, self.phi) expD, expV = self.ref_circuit(gate, [0, 2]) # test the covariance matrix assert np.allclose(resV, expV) # test the vector of means assert np.allclose(resD, expD)
def test_two_mode_gate(self): """Test S2gate gives correct means and cov in global mode""" self.eng.reset() q = self.eng.register H, t = two_mode_squeezing(self.r, self.phi, mode1=0, mode2=2, hbar=self.hbar) resD, resV = self.H_circuit(H, t) gate = S2gate(self.r, self.phi) expD, expV = self.ref_circuit(gate, (q[0], q[2])) # test the covariance matrix self.assertTrue(np.allclose(resV, expV)) # test the vector of means self.assertTrue(np.allclose(resD, expD))
def test_identity(self): """Test alpha=0 gives identity""" self.logTestName() _, t = two_mode_squeezing(0) self.assertEqual(t, 0)
def setUp(self): """Parameters""" self.hbar = 2 self.r = 0.242 self.phi = 0.452 self.H, self.t = two_mode_squeezing(self.r, self.phi, hbar=self.hbar)
def test_time(self, hbar): """Test time parameter is correct""" _, t = two_mode_squeezing(self.r, self.phi, hbar=hbar) assert t == self.r
def test_gaussian(self, hbar): """Test output is gaussian""" H, _ = two_mode_squeezing(self.r, self.phi, hbar=hbar) res = get_quad_operator(H).is_gaussian() assert res
def test_hermitian(self, hbar): """Test output is hermitian""" H, _ = two_mode_squeezing(self.r, self.phi, hbar=hbar) assert is_hermitian(H) assert is_hermitian(get_quad_operator(H))
def test_identity(self): """Test alpha=0 gives identity""" _, t = two_mode_squeezing(0) assert t == 0