Function libwalrus::loop_hafnian_rpt_quad(std::vector<std::complex<double>>&, std::vector<std::complex<double>>&, std::vector<int>&)¶
Defined in File repeated_hafnian.hpp
Function Documentation¶
-
std::complex<double>
libwalrus
::
loop_hafnian_rpt_quad
(std::vector<std::complex<double>> &mat, std::vector<std::complex<double>> &mu, std::vector<int> &rpt) Returns the loop hafnian of a matrix using the algorithm described in From moments of sum to moments of product, doi:10.1016/j.jmva.2007.01.013.
Note that this algorithm, while generally slower than others, can be significantly more efficient in the cases where the matrix has repeated rows and columns.
This is a wrapper around the templated function
libwalrus::hafnian_rpt_loop
for Python integration. It accepts and returns complex double numeric types, and returns sensible values for empty and non-even matrices.In addition, this wrapper function automatically casts all matrices to type
complex<long double>
, allowing for greater precision than supported by Python and NumPy.- Return
loop hafnian of the input matrix
- Parameters
mat
: a flattened vector of size \(n^2\), representing an \(n\times n\) row-ordered symmetric matrix.mu
: a vector of length \(n\) representing the vector of means/displacement.rpt
: a vector of integers, representing the number of times each row/column inmat
is repeated. For example,mat = [1]
andrpt = [6]
represents a \(6\times 6\) matrix of all ones.
Contents
Downloads