Ejemplo n.º 1
0
    def test_quadratic_phase(self, tol):
        """Test the quadratic phase symplectic transform."""

        s = 0.543
        S = quadratic_phase(s)

        # apply to a coherent state. P[x, p] -> [x, p+sx]
        alpha = 0.23+0.12j
        out = S @ np.array([alpha.real, alpha.imag])*np.sqrt(2*hbar)
        expected = np.array([alpha.real, alpha.imag+s*alpha.real])*np.sqrt(2*hbar)
        assert out == pytest.approx(expected, abs=tol)
Ejemplo n.º 2
0
    def test_quadratic_phase(self):
        """Test the quadratic phase symplectic transform."""
        self.logTestName()

        s = 0.543
        S = quadratic_phase(s)

        # apply to a coherent state. P[x, p] -> [x, p+sx]
        alpha = 0.23+0.12j
        out = S @ np.array([alpha.real, alpha.imag])*np.sqrt(2*hbar)
        expected = np.array([alpha.real, alpha.imag+s*alpha.real])*np.sqrt(2*hbar)
        self.assertAllAlmostEqual(out, expected, delta=self.tol)