Skip to main content

aljabr — Implicit linear operators

aljabr is a small Python library providing an interface for implicit linear operators: linear maps defined by forward and adjoint callables rather than an explicit matrix. It is useful when an explicit matrix representation is not adequate — for instance when the dimension is large, when a more efficient algorithm exists, or when the operator is naturally expressed as a function.

A typical example is the Discrete Fourier Transform, which is a linear operator available through fft and ifft functions. aljabr lets you treat it — and compose it with others — as if it were a matrix.

The foundation is the LinOp type. Everything else — concrete operators, utilities, algebraic composition — is built on top of it and optional. I made this library for my own use.

Key differences from similar tools

vs. scipy.sparse.linalg.LinearOperator — input and output arrays can have any shape with aljabr, not just vectors. A 2D FFT operator maps an image to an image. Shapes are fixed at construction: a DFT on a 512² image is a different object than one on a 256² image. This is intentional.

vs. PyLops — aljabr is deliberately minimal. It does not provide solvers or choose algorithms for you. There is no x = A / y. It stays out of your way, offering only readability and convenience.

Features

  • Abstract base class LinOp with forward (A·x) and adjoint (Aᴴ·y)
  • Algebraic composition: A + B, A - B, A @ B, scalar * A, A.H, A.G
  • Array-API compatible — works with NumPy, PyTorch, JAX, and others via array-api-compat
  • Compatible with scipy.sparse.linalg.LinearOperator — can also be passed directly as argument (wrap it with aslinearoperator for eigs and eigsh)
  • Concrete operators: Identity, Diag, DFT, RealDFT, Conv, DirectConv, CircConv, FreqFilter, Diff, Sampling, Slice, wavelet, …
  • Utilities: dottest, fwadjtest, is_sym, is_pos_def, cond, …

Installation

# with poetry (or uv)
poetry add aljabr

# with pip
pip install aljabr

Optional dependencies:

poetry add aljabr[wavelet]   # PyWavelets — required for DWT, Analysis2, Synthesis2
poetry add aljabr[scipy]     # SciPy — required for DirectConv and fcond

Quick example

import numpy as np
import aljabr

# Wrap the FFT as a linear operator
F = aljabr.DFT(shape=(256, 256), ndim=2)

x = np.random.randn(256, 256)

y = F.forward(x)  # F·x
# or
y = F * x
# or
y = F(x)

z = F.adjoint(y)  # Fᴴ·y
# or
z = y * F  # (= Fʰ·yᵗ)

# Algebraic composition
A = aljabr.Diff(ishape=(256, 256), axis=0)
B = A.H @ A  # AᴴA as a Symmetric operator

# Validate with the dot test
from aljabr import dottest

assert dottest(A, num=5)

Documentation

https://aljabr.readthedocs.io

Status

Pre-Alpha. The API may change. Feedback welcome: francois.orieux@universite-paris-saclay.fr

Use with AI agents

  • llms.txt follows the llms.txt proposal and gives agents a map of the documentation.
  • skills/aljabr is an Agent Skill that teaches agents the conventions of aljabr. In Claude Code, install it from this repository, which is also a plugin marketplace:
    /plugin install aljabr --marketplace forieux/aljabr
    
    or with /plugin marketplace add forieux/aljabr then /plugin install aljabr@aljabr. For other agents, copy the skills/aljabr directory into their skills directory.

How AI is used

This project is not vibecoded. But with performant AI agents, I use them for bug tracking and design reflection, not for code writing. I write the code, but the one proposed by the agent is in the window on the side, obviously.

The agent and I write documentation. I reread the agent part, and the agent reread my part, and I chose to commit. The agent writes all tests. I chose that approach because I don't have the time to write all the documentation and tests.

I think this is a good trade-off for a project maintained by one person. It allows me to propose a more polished version of what I publish, as if I were a full-time developer, which is also good for my own use.

License

MIT — see LICENSE.

Metadata

Release files for aljabr 0.7.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aljabr 0.7.0
File Size Uploaded Provenance Actions
aljabr-0.7.0.tar.gz 26.4 kB Without provenance Details for aljabr-0.7.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aljabr 0.7.0
File Interpreter ABI Platform Actions
aljabr-0.7.0-py3-none-any.whl Python 3 none any Details for aljabr-0.7.0-py3-none-any.whl

Total release size: 54.3 kB

Release files / aljabr-0.7.0.tar.gz

Download URL aljabr-0.7.0.tar.gz
Size 26.4 kB
Tags Source
SHA-256 checksum
How to use checksums
07ba0dd6bbabc5b6e448a7028baffb9d696dbd74e3b788c56dd0f6a88c22f271
BLAKE2b-256 checksum
How to use checksums
f3837c3db44b7789a186bf568a97adfffde350a5a3e9b9a1afb8b35714c3a159
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / aljabr-0.7.0-py3-none-any.whl

Download URL aljabr-0.7.0-py3-none-any.whl
Size 27.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c5c9f2d71d008509dbce7cbf909f3a0143a0f5a0ad30ac60ecc5426a8f31d40
BLAKE2b-256 checksum
How to use checksums
5777143f32093e5eecbc915d8f6515e38b49ec590f69dac39ce9a297b284edc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for aljabr 0.7.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page