Template Function libwalrus::hafnian_nonneg

Function Documentation

template<typename T>
long double libwalrus::hafnian_nonneg(std::vector<T> &mat, int &nsamples)

Returns the approximation to the hafnian of a matrix with non-negative entries.

The approximation follows an stochastic algorithm according to which the hafnian can be approximated as the sum of determinants of matrices. The accuracy of the approximation increases with increasing number of iterations.

Return

the approximate hafnian

Parameters
  • mat: vector representing the flattened matrix

  • nsamples: positive integer representing the number of samples to perform