Template Function libwalrus::do_chunk_loops

Function Documentation

template<typename T>
T libwalrus::do_chunk_loops(std::vector<T> &mat, std::vector<T> &C, std::vector<T> &D, 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 loop hafnian of matrix mat.

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

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

Return

the partial sum for the loop hafnian

Parameters
  • mat: vector representing the flattened matrix

  • C: contains the diagonal elements of matrix z

  • D: the diagonal elements of matrix z, with every consecutive pair swapped (i.e., C[0]==D[1], C[1]==D[0], C[2]==D[3], C[3]==D[2], etc.).

  • n: size of the matrix

  • X: initial index of the partial sum

  • chunksize: length of the partial sum