haarpy

Haarpy is a Python library for the symbolic calculation of Weingarten functions and related averages of unitary matrices sampled uniformly at random from the Haar measure.

https://github.com/polyquantique/haarpy

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.0%) to scientific vocabulary

Keywords

group-theory haar-measure quantum-information
Last synced: 6 months ago · JSON representation ·

Repository

Haarpy is a Python library for the symbolic calculation of Weingarten functions and related averages of unitary matrices sampled uniformly at random from the Haar measure.

Basic Info
Statistics
  • Stars: 2
  • Watchers: 0
  • Forks: 0
  • Open Issues: 2
  • Releases: 5
Topics
group-theory haar-measure quantum-information
Created almost 2 years ago · Last pushed 7 months ago
Metadata Files
Readme License Citation

README.md

Test Python Versions PyPI version


Haarpy is a Python library for the symbolic calculation of Weingarten functions and related averages of unitary matrices $U(d)$ sampled uniformly at random from the Haar measure.

The original Mathematica version of this code, for the calculation of Weingarten functions of the unitary group, can be found here.

Haarpy in action

The main functions of Haarpy are weingarten_class, weingarten_element and haar_integral allowing for the calculation of Weingarten functions and integrals over unitaries sampled at random from the Haar measure. We recommend importing the following when working with Haarpy: ```Python from sympy import Symbol from sympy.combinatorics import Permutation

d = Symbol("d") ```

weingarten_class

Takes a partition, labeling a conjugacy class of $Sp$, and a dimension $d$ as arguments. For the conjugacy class labeled by partition $\lbrace 3,1\rbrace$, the function returns ```Python from haarpy import weingartenclass weingartenclass((3,1),d) (2d2 - 3)/(d2(d - 3)(d - 2)(d - 1)(d + 1)(d + 2)*(d + 3)) The previous can also be called with integer values as such Python weingartenclass((3,1),4) 29/20160 ```

weingarten_element

Takes an element and the degree $p$ of the symmetric group $Sp,$ and a dimension $d$ as arguments, the conjugacy class being obtained from the first two. ```Python from haarpy import weingartenelement weingartenelement(Permutation(0,1,2), 4, d) (2d2 - 3)/(d2(d - 3)(d - 2)(d - 1)(d + 1)(d + 2)*(d + 3)) ``` Which yields the same result as before since $\lbrace 3,1\rbrace$ is the class of permutation $(0,1,2)$ in $S4$.

haar_integral

Takes in a tuple of sequences $((i1,\dots,ip),\ (j1,\dots,jp),\ (i\prime1,\dots, i\primep),\ (j\prime1,\dots,j\primep))$, and the dimension $d$ of the unitary group. Returns the value of the integral $\int dU \ U{i1j1}\dots U{ipjp}U^\ast{i\prime1 j\prime1}\dots U^\ast{i\primep j\primep}$. Python from haarpy import haar_integral haar_integral(((1,2), (1,2), (1,2), (1,2)), d) 1/((d-1)*(d+1)) Auxiliary functions include, but are not limited to, the following. For a comprehensive list of functionalities, please refer to the documentation.

murnnakarule

Implementation of the Murnaghan-Nakayama rule for the characters irreducible representations of the symmetric group $Sp$. Takes a partition characterizing an irrep of $Sp$ and a conjugacy class and yields the associate character. Python from haarpy import murn_naka_rule murn_naka_rule((3,1), (1,1,1,1)) 3

getconjugacyclass

Returns the class of a given element of $Sp$ when given the order and the element. ```Python from haarpy import getconjugacyclass getconjugacy_class(Permutation(0,1,2), 4) (3,1) ```

irrep_dimension

Takes a partition labeling an irrep of $Sp$ and returns the dimension of this irrep. ```Python from haarpy import irrepdimension irrep_dimension((5,4,2,1,1,1)) 63063 ```

representation_dimension

Takes a partition labeling a representation of the unitary group $U(d)$, as well as the dimension $d$, and returns the dimension of the representation. Python from haarpy import representation_dimension representation_dimension((5, 4, 2, 1, 1, 1),d) d**2*(d - 5)*(d - 4)*(d - 3)*(d - 2)*(d - 1)**2*(d + 1)**2*(d + 2)**2*(d + 3)*(d + 4)/1382400 Which can also be done numerically. Python ud_dimension((5, 4, 2, 1, 1, 1),8) 873180

Tables of Weingarten functions for $n \le 5$

The following have been retrieved using the weingarten_class function. Weingarten functions of symmetric groups of higher degrees can just as easily be obtained.

Symmetric group $S_2$

|Class| Weingarten | |--|--| |$\lbrace2\rbrace$ |$-\displaystyle\frac{1}{(d-1) d (d+1)}$| | $\lbrace1,1\rbrace$ | $\displaystyle\frac{1}{(d-1)(d+1)}$ |

Symmetric group $S_3$

|Class | Weingarten | |--|--| | $\lbrace 3\rbrace$ | $\displaystyle\frac{2}{(d-2) (d-1) d (d+1) (d+2)}$ | |$\lbrace 2,1\rbrace$|$-\displaystyle\frac{1}{(d-2) (d-1) (d+1) (d+2)}$| | $\lbrace 1,1,1\rbrace$ |$\displaystyle\frac{d^2-2}{(d-2) (d-1) d (d+1) (d+2)}$ |

Symmetric group $S_4$

|Class| Weingarten | |--|--| | $\lbrace 4\rbrace$ |$-\displaystyle\frac{5}{(d-3) (d-2) (d-1) d (d+1) (d+2) (d+3)}$ | |$\lbrace 3,1\rbrace$ |$\displaystyle\frac{2 d^2-3}{(d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3)}$ | |$\lbrace 2,2\rbrace$|$\displaystyle\frac{d^2+6}{(d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3)}$| | $\lbrace 2,1,1\rbrace$| $-\displaystyle\frac{1}{(d-3) (d-1) d (d+1) (d+3)}$| |$\lbrace 1,1,1,1\rbrace$ |$\displaystyle\frac{d^4-8 d^2+6}{(d-3) (d-2) (d-1)d^2 (d+1) (d+2)(d+3)}$|

Symmetric group $S_5$

|Class| Weingarten | |--|--| | $\lbrace 5\rbrace$ |$\displaystyle\frac{14}{(d-4) (d-3) (d-2) (d-1) d (d+1) (d+2) (d+3)(d+4)}$ | |$\lbrace 4,1\rbrace$ |$\displaystyle\frac{24-5 d^2}{(d-4) (d-3) (d-2) (d-1) d^2 (d+1) (d+2)(d+3)(d+4)}$ | | $\lbrace 3,2\rbrace$|$-\displaystyle\frac{2 \left(d^2+12\right)}{(d-4) (d-3) (d-2) (d-1)d^2(d+1)(d+2)(d+3)(d+4)}$| | $\lbrace 3,1,1\rbrace$ | $\displaystyle\frac{2}{(d-4) (d-2) (d-1) d (d+1) (d+2) (d+4)}$| | $\lbrace 2,2,1\rbrace$ |$\displaystyle\frac{-d^4+14 d^2-24}{(d-4) (d-3) (d-2) (d-1) d^2 (d+1) (d+2) (d+3) (d+4)}$| | $\lbrace 1,1,1,1,1\rbrace$|$\displaystyle\frac{d^4-20 d^2+78}{(d-4) (d-3) (d-2) (d-1) d (d+1) (d+2) (d+3) (d+4)}$|

Examples of integrals over Haar-random unitaries

Selected integrals of unitary groups ; $i,j,k$ and $\ell$ are assumed to take distinct integer values in the following. |Integral| Result | |--|--| | $\int dU \ U{ij}U^\ast{ij}$ |$\displaystyle\frac{1}{d}$| | $\int dU \ U{ij}U{kj}U^\ast{ij}U^\ast{kj}$ | $\displaystyle\frac{1}{d(d+1)}$| | $\int dU \ U{ik}U{k\ell}U^\ast{ij}U^\ast{k\ell}$ |$\displaystyle\frac{1}{(d-1)(d+1)}$| | $\int dU \ U{ij}U{k\ell}U^\ast{i\ell}U^\ast{kj}$ | $\displaystyle\frac{-1}{(d-1)d(d+1)}$ | | $\int dU \ U{ij}U{k\ell}U{mn}U^\ast{ij}U^\ast{k\ell}U^\ast{mn}$ | $\displaystyle\frac{d^2-2}{(d-2)(d-1)d(d+1)(d+2)}$ | | $\int dU \ U{i\ell}U{jm}U{kn}U^\ast{im}U^\ast{jn}U^\ast{k\ell}$ | $\displaystyle\frac{2}{(d-2)(d-1)d(d+1)(d+2)}$ | | $\int dU \ U{i\ell}U{j\ell}U{km}U^\ast{i\ell}U^\ast{jm}U^\ast{k\ell}$ | $\displaystyle\frac{-1}{(d-1)d(d+1)(d+2)}$ | | $\int dU \ U{i\ell}U{j\ell}U{k\ell}U^\ast{i\ell}U^\ast{j\ell}U^\ast{k\ell}$ | $\displaystyle\frac{1}{d(d+1)(d+2)}$ | | $\int dU \ U{ij}U{ik}U{i\ell}U{im}U^\ast{ij}U^\ast{ik}U^\ast{i\ell}U^\ast{im}$ | $\displaystyle\frac{1}{d(d + 1)(d + 2)(d + 3)}$ |

Installation

Haarpy requires Python version 3.9 or later. Installation can be done through the pip command pip install haarpy

Compiling from source

Haarpy has the following dependencies: * Python >= 3.9 * SymPy >= 1.12

Documentation

Haarpy documentation is available online on Read the Docs.

How to cite this work

Please cite as: @misc{cardin2024haarpy, author={Cardin, Yanic and de Guise, Hubert and Quesada, Nicol{\'a}s}, title={Haarpy, a Python library for the symbolic calculation of Weingarten functions}, year={2024}, publisher={GitHub}, journal={GitHub repository}, howpublished = {\url{https://github.com/polyquantique/haarpy}}, version = {0.0.5} }

Authors

  • Yanic Cardin, Hubert de Guise, Nicolás Quesada.

License

Haarpy is free and open source, released under the Apache License, Version 2.0.

Owner

  • Name: Polyquantique
  • Login: polyquantique
  • Kind: organization
  • Location: Canada

Quantum Photonics and Information at Polytechnique Montreal

Citation (CITATION.cff)

cff-version: 0.0.1
message: "If you use this software, please cite it as below."
authors:
- family-names: "Cardin"
  given-names: "Yanic"
  orcid:
- family-names: "de Guise"
  given-names: "Hubert"
  orcid: "https://orcid.org/0000-0002-1904-4287"
- family-names: "Quesada"
  given-names: "Nicolás"
  orcid: "https://orcid.org/0000-0002-0175-1688"
title: "haarpy"
version: 0.0.5
doi:
date-released: 2024-06-21
url: "https://github.com/polyquantique/haarpy"

GitHub Events

Total
  • Create event: 10
  • Release event: 1
  • Issues event: 6
  • Delete event: 9
  • Issue comment event: 12
  • Push event: 89
  • Pull request review event: 35
  • Pull request review comment event: 31
  • Pull request event: 15
Last Year
  • Create event: 10
  • Release event: 1
  • Issues event: 6
  • Delete event: 9
  • Issue comment event: 12
  • Push event: 89
  • Pull request review event: 35
  • Pull request review comment event: 31
  • Pull request event: 15

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 4
  • Total pull requests: 9
  • Average time to close issues: about 1 year
  • Average time to close pull requests: about 23 hours
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 0.25
  • Average comments per pull request: 0.78
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 3
  • Pull requests: 9
  • Average time to close issues: N/A
  • Average time to close pull requests: about 23 hours
  • Issue authors: 3
  • Pull request authors: 2
  • Average comments per issue: 0.0
  • Average comments per pull request: 0.78
  • Merged pull requests: 7
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • nquesada (4)
  • yaniccd (2)
  • mduschenes (1)
  • RohanShiatis (1)
  • AmanieOxana (1)
Pull Request Authors
  • yaniccd (7)
  • nquesada (4)
  • sduquemesa (1)
Top Labels
Issue Labels
documentation (1) enhancement (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 28 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 3
  • Total maintainers: 2
pypi.org: haarpy

Symbolic calculation of Weingarten functions

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 28 Last month
Rankings
Dependent packages count: 10.8%
Average: 35.8%
Dependent repos count: 60.8%
Maintainers (2)
Last synced: 7 months ago

Dependencies

.github/workflows/python-publish.yml actions
  • actions/checkout v4 composite
  • actions/setup-python v3 composite
  • pypa/gh-action-pypi-publish 27b31702a0e7fc50959f5ad993c78deac1bdfc29 composite
requirements.txt pypi
  • numpy ==1.26.4
  • sympy ==1.12
setup.py pypi