XanaduAI / thewalrus

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling.
https://the-walrus.readthedocs.io
Apache License 2.0
100 stars 55 forks source link

Add support for calculating the permanent using the BBFG algorithm #263

Closed mlxd closed 3 years ago

mlxd commented 3 years ago

Issue description

Currently, The Walrus uses the Ryser formula to calculate permanents of arbitrary matrices (https://en.wikipedia.org/wiki/Computing_the_permanent#Ryser_formula). Another useful algorithm to calculate permanents is the Balasubramanian–Bax–Franklin–Glynn (BBFG) formula (https://en.wikipedia.org/wiki/Computing_the_permanent#Balasubramanian%E2%80%93Bax%E2%80%93Franklin%E2%80%93Glynn_formula). Having both methods implemented will allow for performance and accuracy comparisons and trade-offs.

Required tasks:

maliasadi commented 3 years ago

Sorta done with adding BBFG support, I think. However, as I've changed the list of requirements just a bit, I'll review what's been done this evening:

My script to test changes before commit:

make clean && \
pip install -e . && \
make test-cpp && \
make test 

Please, let me know if the list of changes cover all concerns within this issue.

mlxd commented 3 years ago

Hi @maliasadi sounds good. Feel free to open a PR with your changes. The team can review and discuss in there.

maliasadi commented 3 years ago

Feel free to open a PR with your changes. The team can review and discuss in there.

Sorry for the late reply @mlxd. I was looking for some time to optimize my code and implement the parallel version (that's not done yet!) before making a PR. I collected some promising benchmarks comparing my two versions of BBFG formula with the Ryser's one. I'll open a PR and continue the conversation there.

nquesada commented 3 years ago

Solved via https://github.com/XanaduAI/thewalrus/pull/267