Template Function libwalrus::do_chunk

Function Documentation

template<typename T>
T libwalrus::do_chunk(std::vector<T> &mat, int n, unsigned long long int X, unsigned long long int chunksize)

Calculates the partial sum \(X,X+1,\dots,X+\text{chunksize}\) using the Cygan and Pilipczuk formula for the hafnian of matrix mat.

Note that if X=0 and chunksize=pow(2.0, n/2), then the full hafnian is calculated.

This function uses OpenMP (if available) to parallelize the reduction.

Return

the partial sum for hafnian

Parameters
  • mat: vector representing the flattened matrix

  • n: size of the matrix

  • X: initial index of the partial sum

  • chunksize: length of the partial sum