Skip to main content

Open source library for hafnian calculation

Project description

CircleCI Appveyor Codecov coverage Codacy grade Read the Docs PyPI - Python Version JOSS - The Journal of Open Source Software

A library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling. For more information, please see the documentation.

Features

  • Fast calculation of hafnians, loop hafnians, and torontonians of general and certain structured matrices.

  • An easy to use interface to use the loop hafnian for Gaussian quantum state calculations.

  • Sampling algorithms for hafnian and torontonians of graphs.

  • Efficient classical methods for approximating the hafnian of non-negative matrices.

  • Easy to use implementations of the multidimensional Hermite polynomials, which can also be used to calculate hafnians of all reductions of a given matrix.

Installation

Pre-built binary wheels are available for the following platforms:

macOS 10.6+

manylinux x86_64

Windows 64bit

Python 3.7

X

X

X

Python 3.8

X

X

X

Python 3.9

X

X

X

To install, simply run

pip install thewalrus

Compiling from source

The Walrus depends on the following Python packages:

In addition, to compile the C++ extension, the following dependencies are required:

  • A C++11 compiler, such as g++ >= 4.8.1, clang >= 3.3, MSVC >= 14.0/2015

  • Cython an optimising static compiler for the Python programming language.

On Debian-based systems, these can be installed via apt and curl:

$ sudo apt install g++
$ pip install Cython

or using Homebrew on MacOS:

$ brew install gcc
$ pip install Cython

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/thewalrus.git
$ cd thewalrus && python -m pip install -e .

OpenMP

libwalrus uses OpenMP to parallelize both the permanent and the hafnian calculation. At the moment, this is only supported on Linux/MacOS using the GNU g++ compiler/Clang.

Software tests

To ensure that The Walrus library is working correctly after installation, the test suite can be run by navigating to the source code folder and running

$ make test

To run the low-level C++ test suite, Googletest will need to be installed. In Ubuntu-based distributions, this can be done as follows:

sudo apt-get install cmake libgtest-dev

Alternatively, the latest Googletest release can be installed from source:

sudo apt install cmake
wget -qO - https://github.com/google/googletest/archive/release-1.8.1.tar.gz | tar -xz
cmake -D CMAKE_INSTALL_PREFIX:PATH=$HOME/googletest -D CMAKE_BUILD_TYPE=Release googletest-release-1.8.1
make install

If installing Googletest from source, make sure that the included headers and libraries are available on your include/library paths.

Documentation

The Walrus documentation is available online on Read the Docs.

To build it locally, you need to have the following packages installed:

They can be installed via a combination of pip and apt if on a Debian-based system:

$ sudo apt install pandoc doxygen
$ pip3 install sphinx sphinxcontrib-bibtex nbsphinx breathe exhale

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.

Contributing to The Walrus

We welcome contributions - simply fork The Walrus repository, and then make a pull request containing your contribution. All contributors to The Walrus will be listed as authors on the releases.

We also encourage bug reports, suggestions for new features and enhancements, and even links to projects, applications or scientific publications that use The Walrus.

Authors

The Walrus is the work of many contributors.

If you are doing research using The Walrus, please cite our paper:

Brajesh Gupt, Josh Izaac and Nicolas Quesada. The Walrus: a library for the calculation of hafnians, Hermite polynomials and Gaussian boson sampling. Journal of Open Source Software, 4(44), 1705 (2019)

Support

If you are having issues, please let us know by posting the issue on our Github issue tracker.

License

The Walrus 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

thewalrus-0.16.2.tar.gz (275.1 kB view hashes)

Uploaded Source

Built Distributions

thewalrus-0.16.2-cp39-cp39-win_amd64.whl (204.5 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

thewalrus-0.16.2-cp39-cp39-manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ x86-64

thewalrus-0.16.2-cp39-cp39-macosx_10_9_x86_64.whl (508.9 kB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

thewalrus-0.16.2-cp38-cp38-win_amd64.whl (205.1 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

thewalrus-0.16.2-cp38-cp38-manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ x86-64

thewalrus-0.16.2-cp38-cp38-macosx_10_9_x86_64.whl (506.3 kB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

thewalrus-0.16.2-cp37-cp37m-win_amd64.whl (203.0 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

thewalrus-0.16.2-cp37-cp37m-manylinux2010_x86_64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ x86-64

thewalrus-0.16.2-cp37-cp37m-macosx_10_9_x86_64.whl (506.5 kB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page