Template Function libwalrus::loop_hafnian_rpt

Function Documentation

template<typename T>
T libwalrus::loop_hafnian_rpt(std::vector<T> &mat, std::vector<T> &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.

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 in mat is repeated. For example, mat = [1] and rpt = [6] represents a \(6\times 6\) matrix of all ones.