Metadata-Version: 2.4
Name: abakus
Version: 0.2.0
Summary: Sparse, vectorized algebra over countably infinite bases: symmetric, quasisymmetric and noncommutative symmetric functions, Clifford and Weyl algebras, polynomials and power series, Lie superalgebras and their enveloping algebras, with integer partitions encoded as bit patterns.
Author: Simon Kapfer
License-Expression: MIT
Project-URL: Homepage, https://github.com/SimonKapfer/abakus
Project-URL: Issues, https://github.com/SimonKapfer/abakus/issues
Keywords: algebra,symmetric functions,integer partitions,Clifford algebra,Weyl algebra,Hopf algebra,combinatorics,numba,quasisymmetric functions,Lie superalgebra,universal enveloping algebra,Virasoro algebra,Kac-Moody algebra,Hall algebra,umbral calculus
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.14
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numba>=0.65.1
Requires-Dist: numpy>=2.4.6
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Dynamic: license-file

# abakus

Sparse, vectorized algebra over countably infinite bases.

Many algebras in mathematics have a countable basis: polynomials in infinitely
many variables, symmetric functions, Clifford and exterior algebras, Weyl
algebras, and universal enveloping algebras
of Lie algebras in PBW bases, which generalize the monomial basis of polynomials.
abakus computes in such algebras directly in a chosen basis, with numpy arrays and
Numba-compiled kernels.

## Ideas

**Vectors and bases.** An element of an algebra is a `Vector`: a finite linear
combination of basis elements, stored as an array of index rows and an array of
coefficients. A basis is a class that knows what its indices mean. It defines
multiplication, comultiplication and changes of basis on basis elements, for whole
arrays of index rows at once, and they extend linearly and multilinearly to vectors.
Tensor products, smash products and linear maps are built uniformly on top of this.
Most of the algebras are Hopf algebras, and abakus computes with that structure: the
coproduct drives smash products and convolution powers of linear maps, dual pairs such
as QSym and NSym or U(𝔫) and 𝒪(N) are related by their pairings, and the product of
U(𝔫) is computed as the transpose of the group law of N.

**The super case.** abakus aims to treat ℤ/2-graded algebras alongside the ordinary
ones. Basis elements carry a parity, tensor products follow the Koszul sign rule, and
coproducts of superalgebras land in the graded tensor product. Clifford and exterior
algebras are superalgebras, and the Lie modules handle Lie superalgebras such as
osp(1|2) and the Neveu–Schwarz algebra, with odd PBW generators of exponent at most 1.

**Combinatorial objects as integers.** An integer partition is encoded by the
boundary of its Ferrers diagram: a step up is a 1 bit, a step right is a 0 bit.
The partition (8, 5, 2, 2) becomes `0b10001000110 == 1094`. Partitions are then
plain integers that live in numpy arrays, and the Pieri, Littlewood–Richardson and
Murnaghan–Nakayama rules become bit operations (see
[docs/BinaryPartitions.md](https://github.com/SimonKapfer/abakus/blob/master/docs/BinaryPartitions.md)).
Compositions, blades of Clifford algebras and the PBW monomials of pronilpotent Lie
algebras are encoded the same way.

**Countably infinite bases, exact coefficients.** Most bases are infinite: all
partitions, all monomials in infinitely many variables. Each vector touches only
finitely many basis elements, and indices grow as needed. Integer and `Fraction`
coefficients stay exact, also under division and changes of basis, and both indices
and coefficients turn into Python integers beyond the int64 range. Wherever there is
an integral basis, such as Kostant's basis of U(𝔤), abakus uses it, so the
structure constants are integers.

## Example

```python
>>> from abakus.symm import s, h, p
>>> s(2, 1) * s(1)              # Littlewood–Richardson rule
s{2,2} + s{3,1} + s{2,1,1}
>>> h(s(2, 1))                  # Jacobi–Trudi
-h{3} + h{2,1}
>>> s(p(3))                     # Murnaghan–Nakayama
s{3} - s{2,1} + s{1,1,1}
>>> s(100) * s(100) == s(h(100, 100))
True

>>> from abakus import bpart
>>> x = bpart.from_lambda([8, 5, 2, 2])
>>> x
1094
>>> bpart.to_lambda(bpart.transpose(x))
[4, 4, 2, 2, 2, 1, 1, 1]

>>> from abakus.clifford import CliffordAlgebraBasis
>>> C = CliffordAlgebraBasis[3, 0]
>>> C(0) * C(1), C(1) * C(0), (C(0) + C(1)) ** 2
(e₀e₁, -e₀e₁, 2)

>>> from abakus.polynomial import PolynomialBasis
>>> from abakus.weyl import polynomial_weyl_basis
>>> W = polynomial_weyl_basis(PolynomialBasis["x"])
>>> W.dx * W.x
1 + x∂

>>> s(2) @ C(0)
s{2}⊗e₀
```

More in the [tutorial](https://github.com/SimonKapfer/abakus/blob/master/docs/Tutorial.md), in
[docs/TensorProducts.md](https://github.com/SimonKapfer/abakus/blob/master/docs/TensorProducts.md), in
[docs/SymmetricFunctions.md](https://github.com/SimonKapfer/abakus/blob/master/docs/SymmetricFunctions.md), in
[docs/BinaryPartitions.md](https://github.com/SimonKapfer/abakus/blob/master/docs/BinaryPartitions.md), in
[docs/QuasisymmetricFunctions.md](https://github.com/SimonKapfer/abakus/blob/master/docs/QuasisymmetricFunctions.md), in
[docs/ShefferSequences.md](https://github.com/SimonKapfer/abakus/blob/master/docs/ShefferSequences.md) and in
[docs/LieAlgebras.md](https://github.com/SimonKapfer/abakus/blob/master/docs/LieAlgebras.md).

## Modules

| Module | Contents |
|---|---|
| `abakus.vector` | `Vector`, `VectorBasis`, tensor products, linear and bilinear maps, spans, changes of basis |
| `abakus.bpart` | integer partitions encoded as ints, scalar and array versions |
| `abakus.compositions` | compositions encoded as ints, shuffles, refinements, ribbons on arrays |
| `abakus.polynomial` | (Laurent) polynomials in finitely or countably many variables, also in divided powers; q-integers, q-factorials, Gaussian binomials in k[q^±1] |
| `abakus.powerseries` | formal power series in one variable, convolution powers, q-series |
| `abakus.sheffer` | Sheffer sequences as bases of K[x] (Roman's umbral calculus), the binomial coefficients x𝐶n |
| `abakus.algorithms` | matrices over an algebra: characteristic polynomial, determinant, adjugate without divisions |
| `abakus.clifford` | Clifford and exterior algebras |
| `abakus.symm` | symmetric functions (e, h, p, m, Schur, forgotten) |
| `abakus.symclass` | class algebras of the symmetric groups, Ivanov–Kerov algebra |
| `abakus.hall` | the Hall algebra of finite abelian p-groups over k[q^±1], Macdonald's ψ |
| `abakus.qsym` | quasisymmetric functions (monomial, fundamental, power sum) |
| `abakus.nsym` | noncommutative symmetric functions (complete, ribbon, elementary, Ψ, Φ), dual to QSym |
| `abakus.weyl` | Weyl algebras as smash products |
| `abakus.lie` | Lie superalgebras: nilpotent 𝔫 with U(𝔫) in PBW bases and the coordinate rings 𝒪(N) of N = exp(𝔫) (`lie.nilpotent`); pronilpotent 𝔫 (`lie.pronilpotent`); triangular 𝔤 = 𝔫₋ ⊕ 𝔥 ⊕ 𝔫₊ with U(𝔤) in Kostant's basis, Verma modules and Shapovalov forms (`lie.triangular`); Virasoro, Neveu–Schwarz, affine Kac–Moody (`lie.periodic`) |

Changes between versions are listed in the
[changelog](https://github.com/SimonKapfer/abakus/blob/master/CHANGELOG.md).

## Installation

```
pip install abakus
```

Requires Python 3.14 or later, numpy and Numba.

For development:

```
pip install -e ".[dev]"
pytest
```

## License

MIT, see [LICENSE](https://github.com/SimonKapfer/abakus/blob/master/LICENSE).
