hafnian_#

Functions for Hafnian

Functions

count_unique_permutations(nums)

Count the number of unique permutations of a list of numbers.

get_submat_haf(a, z)

Get the sub-matrix for hafnian calculation.

hafnian(matrix[, loop])

Calculate the hafnian for symmetric matrix, using the eigenvalue-trace method.

hafnian_batch(matrix[, loop])

Calculate the batch hafnian.

integer_partition(remaining, max_num)

Generate all unique integer partitions of m using integers up to n.

poly_lambda(submat, int_partition, power[, loop])

Get the coefficient of the polynomial.

count_unique_permutations(nums: list | ndarray) float64[source]#

Count the number of unique permutations of a list of numbers.

get_submat_haf(a: Tensor, z: Tensor) Tensor[source]#

Get the sub-matrix for hafnian calculation.

See https://arxiv.org/abs/1805.12498 paragraph after Eq.(3.20)

hafnian(matrix: Tensor, loop: bool = False) Tensor[source]#

Calculate the hafnian for symmetric matrix, using the eigenvalue-trace method.

See https://arxiv.org/abs/2108.01622 Eq.(B3)

hafnian_batch(matrix: Tensor, loop: bool = False) Tensor[source]#

Calculate the batch hafnian.

integer_partition(remaining: int, max_num: int) list[source]#

Generate all unique integer partitions of m using integers up to n.

poly_lambda(submat: Tensor, int_partition: list, power: int, loop: bool = False) Tensor[source]#

Get the coefficient of the polynomial.

See https://arxiv.org/abs/1805.12498 Eq.(3.26) (noting that Eq.(3.26) contains a typo) and https://research-information.bris.ac.uk/ws/portalfiles/portal/329011096/thesis.pdf Eq.(3.80)