Skip to content

Commit

Permalink
Fixed bug #13, fixed clements bug where some phase angles weren't app…
Browse files Browse the repository at this point in the history
…lied, fixed bug in displaced squeezed formula in documentation
  • Loading branch information
josh146 committed May 30, 2018
1 parent c9392a4 commit 0ea44e1
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion doc/conventions/states.rst
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ Displaced squeezed state

In the Fock basis, it has the decomposition

.. math:: |\alpha,z\rangle = e^{-\frac{1}{2}|\alpha|^2-\frac{1}{2}\alpha^*2e^{i\phi}}\tanh{(r)} \sum_{n=0}^\infty\frac{\left[\frac{1}{2}e^{i\phi}\tanh(r)\right]^{n/2}}{\sqrt{n!\cosh(r)}} H_n\left[ \frac{\alpha\cosh(r)+\alpha^*e^{i\phi}\sinh(r)}{\sqrt{e^{i\phi}\sinh(2r)}} \right]|n\rangle
.. math:: |\alpha,z\rangle = e^{-\frac{1}{2}|\alpha|^2-\frac{1}{2}{\alpha^*}^2 e^{i\phi}\tanh{(r)}} \sum_{n=0}^\infty\frac{\left[\frac{1}{2}e^{i\phi}\tanh(r)\right]^{n/2}}{\sqrt{n!\cosh(r)}} H_n\left[ \frac{\alpha\cosh(r)+\alpha^*e^{i\phi}\sinh(r)}{\sqrt{e^{i\phi}\sinh(2r)}} \right]|n\rangle


where :math:`H_n(x)` are the Hermite polynomials defined by :math:`H_n(x)=(-1)^n e^{x^2}\frac{d}{dx}e^{-x^2}`. Alternatively, in the Gaussian formulation, :math:`\bar{\mathbf{r}} = 2 \sqrt{\frac{\hbar}{2}}(\text{Re}(\alpha),\text{Im}(\alpha))` and :math:`\mathbf{V} = R(\phi/2)\begin{bmatrix}e^{-2r} & 0 \\0 & e^{2r} \\\end{bmatrix}R(\phi/2)^T`

Expand Down
2 changes: 1 addition & 1 deletion strawberryfields/backends/gaussianbackend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def state(self, modes=None, **kwargs):
N = qmat.shape[0]//2

# work out if qmat and Amat need to be reduced
if len(modes) < N:
if 0 < len(modes) < N:
# reduce qmat
ind = concatenate([array(modes), N+array(modes)])
rows = ind.reshape((-1, 1))
Expand Down
2 changes: 1 addition & 1 deletion strawberryfields/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ def decompose(self, reg):
cmds.append(Command(BSgate(theta, 0), (reg[n], reg[m]), decomp=True))

for n, expphi in enumerate(self.R):
if np.abs(np.round(expphi, 13)) != 1.0:
if np.round(expphi, 13) != 1.0:
q = log(expphi).imag
cmds.append(Command(Rgate(q), reg[n], decomp=True))

Expand Down
2 changes: 1 addition & 1 deletion strawberryfields/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ def displaced_squeezed_state(a, r, phi, basis='fock', fock_dim=5, hbar=2.):
.. math::
|\alpha,z\rangle = e^{-\frac{1}{2}|\alpha|^2-\frac{1}{2}\alpha^*2e^{i\phi}}\tanh{(r)}
|\alpha,z\rangle = e^{-\frac{1}{2}|\alpha|^2-\frac{1}{2}{\alpha^*}^2 e^{i\phi}\tanh{(r)}}
\sum_{n=0}^\infty\frac{\left[\frac{1}{2}e^{i\phi}\tanh(r)\right]^{n/2}}{\sqrt{n!\cosh(r)}}
H_n\left[ \frac{\alpha\cosh(r)+\alpha^*e^{i\phi}\sinh(r)}{\sqrt{e^{i\phi}\sinh(2r)}} \right]|n\rangle
Expand Down

0 comments on commit 0ea44e1

Please sign in to comment.