Open source library for hafnian calculation
Project description
The fastest exact hafnian library for real and complex matrices. For more information, please see the documentation.
Features
The fastest calculation of the hafnian, loop hafnian, permanent, and torontonian, of general and certain structured matrices.
An easy to use interface to use the loop hafnian to calculate Fock matrix elements of Gaussian states via the included quantum module.
Installation
Pre-built binary wheels are available for the following platforms:
macOS 10.6+ |
manylinux x86_64 |
Windows 64bit |
|
---|---|---|---|
Python 3.5 |
✅ |
✅ |
✅ |
Python 3.6 |
✅ |
✅ |
✅ |
Python 3.7 |
✅ |
✅ |
✅ |
These can be installed using pip:
pip install hafnian
Compiling from source
Hafnian depends on the following Python packages:
In addition, to compile the included Fortran and C++ extensions, the following dependencies are required:
A Fortran compiler, such as gfortran
The LINPACK_Q quadruple precision linear algebra library
A C++11 compiler, such as g++ >= 4.8.1, clang >= 3.3, MSVC >= 14.0/2015
Eigen3 - a C++ header library for linear algebra.
On Debian-based systems, these can be installed via apt and curl:
$ sudo apt install g++ gfortran libeigen3-dev
$ curl -sL -o src/linpack_q_complex.f90 https://raw.githubusercontent.com/josh146/linpack_q_complex/master/linpack_q_complex.f90
or using Homebrew on MacOS:
$ brew install gcc eigen
$ curl -sL -o src/linpack_q_complex.f90 https://raw.githubusercontent.com/josh146/linpack_q_complex/master/linpack_q_complex.f90
Alternatively, you can download the Eigen headers manually:
$ mkdir ~/.local/eigen3 && cd ~/.local/eigen3
$ wget http://bitbucket.org/eigen/eigen/get/3.3.7.tar.gz -O eigen3.tar.gz
$ tar xzf eigen3.tar.gz eigen-eigen-323c052e1731/Eigen --strip-components 1
$ export EIGEN_INCLUDE_DIR=$HOME/.local/eigen3
Note that we export the environment variable EIGEN_INCLUDE_DIR so that Hafnian can find the Eigen3 header files (if not provided, Hafnian will by default look in /use/include/eigen3 and /usr/local/include/eigen3).
Once all dependencies are installed, you can compile the latest stable version of the Hafnian library as follows:
$ python -m pip install hafnian --no-binary :all:
Alternatively, you can compile the latest development version by cloning the git repository, and installing using pip in development mode.
$ git clone https://github.com/XanaduAI/hafnian.git
$ cd hafnian && python -m pip install -e .
OpenMP
The Hafnian library uses OpenMP to parallelize both the permanent and the hafnian calculation. At the moment, this is only supported on Linux using the GNU g++ compiler, due to insufficient support using Windows/MSCV and MacOS/Clang.
Using LAPACK, OpenBLAS, or MKL
If you would like to take advantage of the highly optimized matrix routines of LAPACK, OpenBLAS, or MKL, you can optionally compile the Hafnian library such that Eigen uses these frameworks as backends. As a result, all calls in the Hafnian library to Eigen functions are silently substituted with calls to LAPACK/OpenBLAS/MKL.
For example, for LAPACK integration, make sure you have the lapacke C++ LAPACK bindings installed (sudo apt install liblapacke-dev in Ubuntu-based Linux distributions), and then compile with the environment variable USE_LAPACK=1:
$ USE_LAPACK=1 python -m pip install hafnian --no-binary :all:
Alternatively, you may pass USE_OPENBLAS=1 to use the OpenBLAS library.
Software tests
To ensure that the Hafnian library is working correctly after installation, the test suite can be run by navigating to the source code folder and running
$ make test
Documentation
The Hafnian+ documentation is currently not hosted online. To build it locally, you need to have the following packages installed:
Sphinx >=1.5
sphinxcontrib-bibtex >=0.3.6
They can be installed via a combination of pip and apt if on a Debian-based system:
$ sudo apt install pandoc $ pip3 install sphinx sphinxcontrib-bibtex nbsphinx --user
To build the HTML documentation, go to the top-level directory and run the command
$ make doc
The documentation can then be found in the docs/_build/html/ directory.
Support
Source Code: https://github.com/XanaduAI/hafnian
Issue Tracker: https://github.com/XanaduAI/hafnian/issues
If you are having issues, please let us know by posting the issue on our Github issue tracker.
License
Hafnian is free and open source, released under the Apache License, Version 2.0.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file hafnian-0.5.0.tar.gz
.
File metadata
- Download URL: hafnian-0.5.0.tar.gz
- Upload date:
- Size: 202.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a92d941589a50d9e983c46d9b9e5bb9f3e73bf88ca4718cc52f59978e0158f4 |
|
MD5 | 0e1073890c63a39e23cfe87f7f30596f |
|
BLAKE2b-256 | 5cdb435de84667bd23c20e9d536b74afbca9adf616f725934db5100275502c39 |
File details
Details for the file hafnian-0.5.0-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 826.1 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b703aabd13a1c65eb6585306776dbc43327f64d23f115b1f0c57f9daef720a |
|
MD5 | 5f01d2fe13d0a86f433354ab3e2fcd71 |
|
BLAKE2b-256 | 25e41ba9793086d7e1cd1870739af5c0367d4ef4c2edfb3ae27850c4b54f57ed |
File details
Details for the file hafnian-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp37-cp37m-manylinux1_x86_64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.7m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bfa6454ac0b58140cb50450724e1dafb9d74f193e3cf226c42d845ba8657fef |
|
MD5 | 3233368e0bd55e6159bea3d723ed64b3 |
|
BLAKE2b-256 | 0a75375fc7596222f5d5a898e0538d93e2b36e8d1a8ad8ecf80a7255f3f4323f |
File details
Details for the file hafnian-0.5.0-cp37-cp37m-macosx_10_6_intel.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp37-cp37m-macosx_10_6_intel.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.7m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c367e5aa994bf8b3028c0ca6abc846adf01f9f4ed6ef25fff1b90c911e55503c |
|
MD5 | a988048dc6891bea769bccd276ebd8d8 |
|
BLAKE2b-256 | 506485c605005de74d9669831505b9e16b3dd66a7b7f51591c72c0c65cef4667 |
File details
Details for the file hafnian-0.5.0-cp36-cp36m-win_amd64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp36-cp36m-win_amd64.whl
- Upload date:
- Size: 826.2 kB
- Tags: CPython 3.6m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 215bfa747f00c9a11340a410e724e5f1ea9f5cdb82808446844fced586bb5d70 |
|
MD5 | 5282b1939d8e6be065216bea26baf596 |
|
BLAKE2b-256 | d51c443b0fb46880e959de02cd19ebfb5f83c66aab6f0d3b55cc5d975af1a19c |
File details
Details for the file hafnian-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp36-cp36m-manylinux1_x86_64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.6m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 789ff6f26af1d175fd551d654e4dda6ead85c637194399ee19de0eb292734633 |
|
MD5 | a7ecb00c99637f9b0d38a0eb0601b53c |
|
BLAKE2b-256 | 8513239f8001191974dfefc8c9f00c0c79583f7475d87d1f3c56ea7e81ad677a |
File details
Details for the file hafnian-0.5.0-cp36-cp36m-macosx_10_6_intel.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp36-cp36m-macosx_10_6_intel.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.6m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d56149894c36b52516ca08c66b4384b8b65164e2b98935f8dfd3bca85cd4597 |
|
MD5 | aca957d3ed61201e6cc4e324771cdfbf |
|
BLAKE2b-256 | ec52bd56bd1f84df5099889142f1515d9dbb57b64ade3337708291e64575b418 |
File details
Details for the file hafnian-0.5.0-cp35-cp35m-win_amd64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp35-cp35m-win_amd64.whl
- Upload date:
- Size: 826.2 kB
- Tags: CPython 3.5m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88c85035b8e184f09fb13b0362de870092992bf4e5884fa811b284a1e7774aaa |
|
MD5 | 011f791df2e57ed250348fee89f23ff1 |
|
BLAKE2b-256 | 088192013e8861c4aa0a2804fb22d501e78f737134588aeeda59a9e6a5b631f2 |
File details
Details for the file hafnian-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp35-cp35m-manylinux1_x86_64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.5m
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ce77b0b8ab8740c3a8c9427a725e98fd6ae8172ef4844f94edeea4b3f3ceee5 |
|
MD5 | a38f67a1370cf816a355ea6332823337 |
|
BLAKE2b-256 | 7d1ac5dbf2141487a3a547629c10c559c01e9d19294be3a693d383ea69e3e9b3 |
File details
Details for the file hafnian-0.5.0-cp35-cp35m-macosx_10_6_intel.whl
.
File metadata
- Download URL: hafnian-0.5.0-cp35-cp35m-macosx_10_6_intel.whl
- Upload date:
- Size: 2.0 MB
- Tags: CPython 3.5m, macOS 10.6+ intel
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.19.1 setuptools/40.0.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6d3b37174a7b1437334b80b76cf691c61ccb96fb144df146c15e9f8859ff18d |
|
MD5 | 53f3b41ddffe3beee52224b391ea2415 |
|
BLAKE2b-256 | 14158d08a65a5bfae779624f875af9b8ce1b1fa04a233f404982f43f68842efa |