diff --git a/docs/algorithms.rst b/docs/algorithms.rst index 70119ce67..24b54cd23 100644 --- a/docs/algorithms.rst +++ b/docs/algorithms.rst @@ -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 diff --git a/docs/gbs.rst b/docs/gbs.rst index fdb2ed6e7..04bcee7c6 100644 --- a/docs/gbs.rst +++ b/docs/gbs.rst @@ -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. diff --git a/docs/hermite.rst b/docs/hermite.rst index cd9b41737..526f5ad8b 100644 --- a/docs/hermite.rst +++ b/docs/hermite.rst @@ -10,18 +10,18 @@ Multidimensional Hermite polynomials ==================================== .. sectionauthor:: Nicolás Quesada -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 @@ -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. diff --git a/docs/references.bib b/docs/references.bib index 7f37a00ee..a8c728c9e 100644 --- a/docs/references.bib +++ b/docs/references.bib @@ -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} } diff --git a/hafnian/__init__.py b/hafnian/__init__.py index e0c9b2b50..c38475254 100644 --- a/hafnian/__init__.py +++ b/hafnian/__init__.py @@ -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 `__. - 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 @@ -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 `__. + 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. @@ -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 `__. + :cite:`dodonov1994multidimensional`. Python wrappers --------------- diff --git a/hafnian/_hermite_multidimensional.py b/hafnian/_hermite_multidimensional.py index b9ff1db7c..3c52697f7 100644 --- a/hafnian/_hermite_multidimensional.py +++ b/hafnian/_hermite_multidimensional.py @@ -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 diff --git a/hafnian/quantum.py b/hafnian/quantum.py index d6e9dbcfb..10c9ba98b 100644 --- a/hafnian/quantum.py +++ b/hafnian/quantum.py @@ -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). `_ * 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). ` + "Simulating realistic non-Gaussian state preparation." `arXiv:1905.07011. (2019). `_ Fock states @@ -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`. @@ -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`. diff --git a/hafnian/reference.py b/hafnian/reference.py index be69006fb..7ca30966d 100644 --- a/hafnian/reference.py +++ b/hafnian/reference.py @@ -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.