Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor typos correction #33

Merged
merged 7 commits into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/algorithms.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,12 @@ Compare this with Björklund's algorithm, which requires :math:`O\left((A n)^3 \

Batched algorithm
-----------------
Using the Hermite polynomials, and their connection to the matrix elements of Gaussian states and hafnians discussed in the next section, one can calculate the hafnians of all reductions of a matrix :math:`\mathbf{A}` up to a given cutoff. The reduction of matrix :math:`\mathbf{B}` is precisely the matrix :math:`\mathbf{B}_{\mathbf{m}}` obtained by repeating (or removing) the :math:`i^{\text{th}}` row and column :math:`m_i` times. Thus given a cutoff :math:`m_{\max}`, one can use the batched algorithm to calculate
Using the multidimensional Hermite polynomials, and their connection to the matrix elements of Gaussian states and hafnians discussed in the next section, one can calculate the hafnians of all reductions of a matrix :math:`\mathbf{B} \in \mathbb{C}^{n \times n}` up to a given cutoff. The reduction of matrix :math:`\mathbf{B}` is precisely the matrix :math:`\mathbf{B}_{\mathbf{m}}` obtained by repeating (or removing) the :math:`i^{\text{th}}` row and column :math:`m_i` times. Thus given a cutoff :math:`m_{\max}`, one can use the batched algorithm to calculate

.. math::
\text{haf}\left( \mathbf{B}_\mathbf{m} \right)

for all :math:`0\leq m_i < m_{\max}`, thus this function returns a tensor with :math:`n^{m_{\max}}` components.
for all :math:`0\leq m_i < m_{\max}`, thus this function returns a tensor with :math:`(m_{\max})^n` components.

One can also use this function to calculate the same loop hafnians that Kan's algorithm returns

Expand Down
4 changes: 2 additions & 2 deletions docs/gbs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ The variables :math:`(\alpha_0,\ldots,\alpha_{\ell-1})` are said to be complex n

where :math:`{Z} = \left( \begin{smallmatrix} \mathbb{I} & 0\\ 0& -\mathbb{I} \end{smallmatrix} \right)`. The covariance matrix :math:`\sigma` is customarily parametrized in the following block form :cite:`picinbono1996second`

.. math:: \sigma = \left(\begin{array}{c|c}
.. math:: \sigma = \left[\begin{array}{c|c}
\Gamma & C \\
\hline
C^* & \Gamma^*
\end{array} \right),
\end{array} \right],

where :math:`\Gamma` is hermitian and positive definite, while :math:`C` is symmetric.

Expand Down
12 changes: 6 additions & 6 deletions docs/hermite.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ Multidimensional Hermite polynomials
====================================
.. sectionauthor:: Nicolás Quesada <nicolas@xanadu.ai>

In this section we study the multidimensional Hermite polynomials. These polynomials where originally introduced by C. Hermite in 1865. Mizrahi :cite:`mizrahi1975generalized` provides an exhaustive reference on these subject. We however, follow the succinct treatment of Kok and Braunstein :cite:`kok2001multi`.
In this section we study the multidimensional Hermite polynomials originally introduced by C. Hermite in 1865. Mizrahi :cite:`mizrahi1975generalized` provides an exhaustive reference on these subject. We however, follow the succinct treatment of Kok and Braunstein :cite:`kok2001multi`.

In the next section, where we discuss Gaussian states we will explain how these polynomials relate to hafnians and loop hafnians. For the moment just let us introduce them and study their formal properties.
In the next section, where we discuss quantum Gaussian states, we will explain how these polynomials relate to hafnians and loop hafnians. For the moment just let us introduce them and study their formal properties.

Generating function definition
******************************
Given two complex vectors :math:`\alpha,\beta \in \mathbb{C}^\ell` and a symmetric matrix :math:`\mathbf{B} = \mathbf{B}^T \in \mathbb{C}^{\ell \times \ell}`,

.. math::
G_B(\alpha,\beta) = \exp\left( \alpha \mathbf{B} \beta^T - \tfrac{1}{2}\beta \mathbf{B} \beta^T\right) = \sum_{\mathbf{m} \geq \mathbf{0}} \prod_{i=1}^{\ell} \frac{\beta_i^{n_i}}{n_i} H_{\mathbf{m}}^{(\mathbf{B})}(\alpha),
G_B(\alpha,\beta) = \exp\left( \alpha \mathbf{B} \beta^T - \tfrac{1}{2}\beta \mathbf{B} \beta^T\right) = \sum_{\mathbf{m} \geq \mathbf{0}} \prod_{i=1}^{\ell} \frac{\beta_i^{m_i}}{m_i!} H_{\mathbf{m}}^{(\mathbf{B})}(\alpha),

where the notation :math:`\mathbf{m} \geq \mathbf{0}` is used to indicate that the sum goes over all vectors in :math:` \mathbb{N}^{\ell}_0` (the set of vectors of nonnegative integers of size :math:`\ell`). This generating function provides an implicit definition of the multidimensional Hermite polynomials.
where the notation :math:`\mathbf{m} \geq \mathbf{0}` is used to indicate that the sum goes over all vectors in :math:`\mathbb{N}^{\ell}_0` (the set of vectors of nonnegative integers of size :math:`\ell`). This generating function provides an implicit definition of the multidimensional Hermite polynomials.
It is also straightforward to verify that :math:`H_{\mathbf{0}}^{(\mathbf{B})}(\alpha) = 1`.

In the one dimensional case, :math:`\ell=1`, one can compare the generating function above with the ones for the "probabilists' Hermite polynomials" :math:`He_n(x)` and "physicists' Hermite polynomials" :math:`H_n(x)` to find
Expand All @@ -39,10 +39,10 @@ Recursion relation
Based on the generating function introduced in the previous section one can derive the following recursion relation

.. math::
H_{\mathbf{m}+\mathbf{e}_i}^{(\mathbf{B})}(\alpha) - \sum_{j=1}^\ell B_{i,j} \alpha_j H_{\mathbf{m}}^{(\mathbf{B})}(\alpha) + \sum_{j=1}^\ell B_{i,j} m_j H_{\mathbf{m}-\mathbf{e}_j}^{(\mathbf{B})}(\alpha) = 0,
H_{\mathbf{m}+\mathbf{e}_i}^{(\mathbf{B})}(\alpha) - \left(\sum_{j=1}^\ell B_{i,j} \alpha_j \right) H_{\mathbf{m}}^{(\mathbf{B})}(\alpha) + \sum_{j=1}^\ell B_{i,j} m_j H_{\mathbf{m}-\mathbf{e}_j}^{(\mathbf{B})}(\alpha) = 0,


where :math:`\mathbf{e}_j` is a vector with zeros in all its entries except in the :math:`i^{\text{th}}` element.
where :math:`\mathbf{e}_j` is a vector with zeros in all its entries except in the :math:`i^{\text{th}}` entry where it has a one.



Expand Down
2 changes: 1 addition & 1 deletion docs/references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ @article{kan2008moments
@book{TAOCP,
title={The Art of Computer Programming, Vol. 2: Seminumerical Algorithms},
author={Donald E. Knuth},
publisher={Addison-Wesley},
publisher={Addison-Wesley},
year={1998},
edition={3}
}
Expand Down
13 changes: 7 additions & 6 deletions hafnian/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
Eigenvalue hafnian algorithm
The algorithm described in
*A faster hafnian formula for complex matrices and its benchmarking on the Titan supercomputer*,
`arxiv:1805.12498 <https://arxiv.org/abs/1805.12498>`__.
This algorithm scales like :math:`\mathcal{O}(n^3 2^{n/2})`, and supports caclulation of
:cite:`bjorklund2018faster`.
This algorithm scales like :math:`\mathcal{O}(n^3 2^{n/2})`, and supports calculation of
the loop hafnian.

Recursive hafnian algorithm
Expand All @@ -37,13 +37,14 @@
currently support the loop hafnian.

Repeating hafnian algorithm
The algorithm described in *From moments of sum to moments of product*,
`doi:10.1016/j.jmva.2007.01.013 <https://dx.doi.org/10.1016/j.jmva.2007.01.013>`__.
The algorithm described in *From moments of sum to moments of product*, :cite:`kan2008moments`.
This method is more efficient for matrices with repeated rows and columns, and supports caclulation of
the loop hafnian.

Approximate hafnian algorithm
An algorithm that allows us to efficiently approximate the hafnian of
The algorithm described in *Polynomial time algorithms to approximate permanents and mixed discriminants
within a simply exponential factor*, :cite:`barvinok1999polynomial`.
This algorithm allows us to efficiently approximate the hafnian of
matrices with non-negative elements. This is done by sampling determinants;
the larger the number of samples taken, the higher the accuracy.

Expand All @@ -52,7 +53,7 @@
a given matrix up to the cutoff (resolution) provided. Internally, this algorithm
makes use of the multidimensional Hermite polynomials as per
*Multidimensional Hermite polynomials and photon distribution for polymode mixed light*
`arxiv:9308033 <https://arxiv.org/abs/hep-th/9308033>`__.
:cite:`dodonov1994multidimensional`.

Python wrappers
---------------
Expand Down
2 changes: 1 addition & 1 deletion hafnian/_hermite_multidimensional.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def hafnian_batched(A, cutoff, mu=None, tol=1e-12, renorm=False, make_tensor=Tru
cutoff (int): maximum size of the subindices in the Hermite polynomial
mu (array): a vector of length :math:`N` representing the vector of means/displacement
renorm (bool): If ``True``, the returned hafnians are *normalized*, that is,
:math:`haf(reduction(A, k))/\prod(\prod_i k_i!)`
:math:`haf(reduction(A, k))/\prod_i k_i!`
(or :math:`lhaf(fill\_diagonal(reduction(A, k),reduction(mu, k)))` if
``mu`` is not None)
make_tensor: If ``False``, returns a flattened one dimensional array instead
Expand Down
13 changes: 6 additions & 7 deletions hafnian/quantum.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,10 @@

* Quesada, N.
"Franck-Condon factors by counting perfect matchings of graphs with loops."
`Journal of Chemical Physics 150, 164113 (2019). 10.1063/1.5086387>`_
`Journal of Chemical Physics 150, 164113 (2019). <https://aip.scitation.org/doi/10.1063/1.5086387>`_

* Quesada, N., Helt, L. G., Izaac, J., Arrazola, J. M., Shahrokhshahi, R., Myers, C. R., & Sabapathy, K. K.
"Simulating realistic non-Gaussian state preparation."
`arXiv:1905.07011. (2019). <https://arxiv.org/abs/1905.07011>`
"Simulating realistic non-Gaussian state preparation." `arXiv:1905.07011. (2019). <https://arxiv.org/abs/1905.07011>`_


Fock states
Expand Down Expand Up @@ -165,10 +164,10 @@ def Sympmat(N):


def Qmat(cov, hbar=2):
r"""Returns the :math:`Q` matrix of the Gaussian state.
r"""Returns the :math:`Q` Husimi matrix of the Gaussian state.

Args:
cov (array): :math:`2N\times 2N` covariance matrix
cov (array): :math:`2N\times 2N xp-` Wigner covariance matrix
hbar (float): the value of :math:`\hbar` in the commutation
relation :math:`[\x,\p]=i\hbar`.

Expand All @@ -194,11 +193,11 @@ def Qmat(cov, hbar=2):


def Covmat(Q, hbar=2):
r"""Returns the covariance matrix in the :math:`xp`-ordering of the Gaussian state.
r"""Returns the Wigner covariance matrix in the :math:`xp`-ordering of the Gaussian state.
This is the inverse function of Qmat.

Args:
Q (array): :math:`2N\times 2N` Q matrix
Q (array): :math:`2N\times 2N` Husimi Q matrix
hbar (float): the value of :math:`\hbar` in the commutation
relation :math:`[\x,\p]=i\hbar`.

Expand Down
2 changes: 1 addition & 1 deletion hafnian/reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def partitions(s, singles=True, pairs=True):
def T(n):
r"""Returns the :math:`n` th telephone number.

They satisfy the recursion relation :math:`T(n) = T(n-1)+(n-1)T(n-1)` and
They satisfy the recursion relation :math:`T(n) = T(n-1)+(n-1)T(n-2)` and
:math:`T(0)=T(1)=1`.

See https://oeis.org/A000085 for more details.
Expand Down