def test_rotated_squeezed(self, setup_eng, hbar, tol): """Testing a rotated squeezed state""" eng, prog = setup_eng(3) r = 0.1 phi = 0.2312 v1 = (hbar / 2) * np.diag([np.exp(-r), np.exp(r)]) cov = xpxp_to_xxpp(block_diag(*[rot(phi) @ v1 @ rot(phi).T] * 3)) with prog.context as q: ops.Gaussian(cov, decomp=False) | q state = eng.run(prog).state assert np.allclose(state.cov(), cov, atol=tol)
def test_rotated_squeezed(self, setup_eng, hbar, tol): """Testing decomposed rotated squeezed state""" eng, prog = setup_eng(3) r = 0.1 phi = 0.2312 v1 = (hbar / 2) * np.diag([np.exp(-r), np.exp(r)]) A = changebasis(3) cov = A.T @ block_diag(*[rot(phi) @ v1 @ rot(phi).T] * 3) @ A with prog.context as q: ops.Gaussian(cov) | q state = eng.run(prog).state assert np.allclose(state.cov(), cov, atol=tol) assert len(eng.run_progs[-1]) == 3
def test_rotated_squeezed(self, setup_eng, hbar, tol): """Testing a rotated squeezed state""" eng, prog = setup_eng(3) r = 0.1 phi = 0.2312 v1 = (hbar / 2) * np.diag([np.exp(-r), np.exp(r)]) A = changebasis(3) cov = A.T @ block_diag(*[rot(phi) @ v1 @ rot(phi).T] * 3) @ A with prog.context as q: ops.Gaussian(cov, decomp=False) | q state = eng.run(prog).state indices = from_xp(3) cov = cov[:, indices][indices, :] assert np.allclose(state.covs(), np.expand_dims(cov, axis=0), atol=tol)
def test_rotated_squeezed(self, setup_eng, cutoff, hbar, tol): eng, prog = setup_eng(3) r = 0.1 phi = 0.2312 in_state = squeezed_state(r, phi, basis="fock", fock_dim=cutoff) v1 = (hbar / 2) * np.diag([np.exp(-2 * r), np.exp(2 * r)]) cov = xpxp_to_xxpp(block_diag(*[rot(phi) @ v1 @ rot(phi).T] * 3)) with prog.context as q: ops.Gaussian(cov) | q state = eng.run(prog).state assert len(eng.run_progs[-1]) == 3 for n in range(3): assert np.allclose(state.fidelity(in_state, n), 1, atol=tol)