Metadata-Version: 2.1
Name: pfapack
Version: 1.1.0
Summary: Efficient numerical computation of the Pfaffian for dense and banded skew-symmetric matrices.
Author-Email: Bas Nijholt <bas@nijho.lt>, Michael Wimmer <m.t.wimmer@tudelft.nl>
License: MIT
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Utilities
Classifier: License :: OSI Approved :: MIT License
Project-URL: homepage, https://github.com/basnijholt/pfapack
Project-URL: repository, https://github.com/basnijholt/pfapack
Project-URL: documentation, https://pfapack.readthedocs.io
Requires-Python: >=3.10
Requires-Dist: scipy
Requires-Dist: numpy
Provides-Extra: docs
Requires-Dist: sphinx; extra == "docs"
Requires-Dist: sphinx-rtd-theme; extra == "docs"
Requires-Dist: myst-parser; extra == "docs"
Requires-Dist: sphinxcontrib.apidoc; extra == "docs"
Provides-Extra: dev
Requires-Dist: pre-commit; extra == "dev"
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Requires-Dist: pytest-cov; extra == "test"
Requires-Dist: pytest-mypy; extra == "test"
Requires-Dist: tox; extra == "test"
Description-Content-Type: text/markdown

# `pfapack`: Efficient numerical computation of the Pfaffian for dense and banded skew-symmetric matrices

Code and algorithms are taken from [arXiv:1102.3440](https://arxiv.org/abs/1102.3440) which is authored by [Michael Wimmer](https://michaelwimmer.org/).

[![pytest](https://github.com/basnijholt/pfapack/workflows/pytest/badge.svg)](https://github.com/basnijholt/pfapack/actions?query=workflow%3Apytest)
[![codecov](https://img.shields.io/codecov/c/github/basnijholt/pfapack)](https://codecov.io/gh/basnijholt/pfapack)
[![docs](https://img.shields.io/readthedocs/pfapack)](https://pfapack.readthedocs.io)
[![version](https://img.shields.io/pypi/v/pfapack)](https://pypi.org/project/pfapack/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pfapack)](https://pypi.org/project/pfapack/)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

### Install

```bash
pip install pfapack
```

Or using conda:
```bash
conda install -c conda-forge pfapack
```

## Usage

```python
from pfapack import pfaffian as pf
import numpy.random

A = numpy.random.rand(100, 100)
A = A - A.T
pfa1 = pf.pfaffian(A)
pfa2 = pf.pfaffian(A, method="H")
pfa3 = pf.pfaffian_schur(A)
print(pfa1, pfa2, pfa3)
```

The package includes optimized C/FORTRAN implementations that can be used for better performance:
```python
from pfapack.ctypes import pfaffian as cpf
pfa1 = cpf(A)
pfa2 = cpf(A, method="H")
print(pfa1, pfa2)
```

> [!WARNING]
> On Windows, the C bindings require MSYS2 to be installed with the MinGW64 toolchain. The current Windows build system has some limitations and requires external dependencies. We welcome contributions to improve the Windows build system, such as using Microsoft's toolchain (MSVC) directly or finding better ways to handle the OpenBLAS dependency.

## Citing

If you have used `pfapack` in your research, please cite it using the following `bib` entry:
```
@article{wimmer2012algorithm,
    title={Efficient numerical computation of the pfaffian for dense and banded skew-symmetric matrices},
    author={Michael Wimmer},
    journal={ACM Transactions on Mathematical Software (TOMS)},
    volume={38},
    number={4},
    pages={1--17},
    year={2012},
    publisher={ACM New York, NY, USA}
}
```

## License
MIT License

## Contributions
- Bas Nijholt
- [Michael Wimmer (author of the algorithms)](https://arxiv.org/abs/1102.3440)
