Skip to main content

AlgebraX Banner

AlgebraX

Algebraic Primitives for Sparse Data Structures in Python

Package PyPI - Version PyPI - Status PyPI - Python Version PyPI - Downloads PyPI - Dependents Libraries.io SourceRank
Code GitHub GitHub repo size GitHub last commit (by committer) Contributors
Tools PyCharm uv Ruff Hatch project commitizen Zensical
CI/CD Test Publish Publish Publish Docs
Scans Coverage Quality Gate Status Security Rating Maintainability Rating Reliability Rating Lines of Code Vulnerabilities Bugs Codacy Quality Codacy Coverage CodeFactor Snyk

algebrax treats Python's native dict as a first-class sparse algebraic object, unifying linear algebra, graph algorithms, formal language theory, signal transforms, and information metrics under a single polymorphic framework.

Key Features

  • Zero Heavy Dependencies: Pure Python core requiring no C++ build steps. Includes native bidirectional converters between sparse dict mappings and dense multidimensional arrays.
  • 🔄 Polymorphic Semiring Computing: By swapping the algebraic semiring $(\oplus, \otimes)$, the exact same matrix algorithms compute standard linear algebra, tropical shortest path latencies, or symbolic rule provenance.
  • 🌌 Sparse Multidimensional Tensors: Arbitrary nested mappings behave as infinite-dimensional sparse tensors, tries, and lattices (AlgebraicTrie) with custom key operators.
  • 🔬 Interactive Desktop GUI: Repo includes DearPyGui with 12 interactive modules, dynamic texture previews, force-directed graph canvases, and signal transforms.

Installation

# Using uv (recommended)
uv add algebrax

# Using pip
pip install algebrax

5-Minute Quickstart

By changing the semiring parameter in matrix.dot, you can transform standard linear matrix multiplication into shortest-path solvers or symbolic rule drivation tracking:

from algebrax.matrix import dot
from algebrax.semiring import ProvenanceSemiring, StandardSemiring, TropicalSemiring

# Define a Sparse Graph Adjacency / Distance Matrix
graph = {
    0: {1: 2.0, 2: 10.0},
    1: {2: 3.0},
}

# 1. Standard Linear Matrix Multiplication (+, *)
linear_mult = dot(graph, graph, semiring=StandardSemiring())
print('Linear Combination (0->2):', linear_mult[0][2])
# Output: 30.0

# 2. Tropical Shortest Path (min, +)
shortest_path = dot(graph, graph, semiring=TropicalSemiring())
print('Shortest Path Cost (0->1->2):', shortest_path[0][2])
# Output: 5.0

# 3. Symbolic Provenance Rule Tracking
provenance_graph = {
    0: {1: {('rule_A',): 1}, 2: {('rule_C',): 1}},
    1: {2: {('rule_B',): 1}},
}
provenance_mult = dot(provenance_graph, provenance_graph, semiring=ProvenanceSemiring())
print('Symbolic Derivation Polynomial:', provenance_mult[0][2])
# Output: {('rule_A', 'rule_B'): 1}

Use Case Recipes & Jupyter Notebooks

The reciepes/ directory contains standalone CLI scripts and matching interactive .ipynb notebooks for 19 real-world scenarios:

Category Use Case Recipe Script Jupyter Notebook Core Algebraic Components
Image Processing image_processing.py image_processing.ipynb transforms.convolve, StandardSemiring, ArcticSemiring, TropicalSemiring
Traffic Resilience traffic_network_resilience.py traffic_network_resilience.ipynb semiring.TropicalSemiring, matrix.power, analysis.forman_ricci_curvature
NLP Parsing nlp_provenance_parser.py nlp_provenance_parser.ipynb matrix.dot, semiring.ProvenanceSemiring, probability.entropy
Post-Quantum Security post_quantum_crypto_exchange.py post_quantum_crypto_exchange.ipynb semiring.DigitalSemiring, transforms.z_transform, probability.mutual_information
Supply Chain Logistics supply_chain_optimal_transport.py supply_chain_optimal_transport.ipynb trie.AlgebraicTrie, lattice.join, lattice.meet, probability.kl_divergence
Financial Risk financial_risk_portfolio.py financial_risk_portfolio.ipynb automata.simulate_dfa, matrix.academic.eigen_centrality, semiring.VarianceSemiring
Structural Analysis vibration_structural_analysis.py vibration_structural_analysis.ipynb group.compose, group.signature, matrix.academic.determinant, transforms.hilbert
Telecommunications telecom_fractal_network.py telecom_fractal_network.ipynb transforms.walsh_hadamard, analysis.laplacian, metrics.box_counting_dimension
Quantum Optimization quantum_convex_optimization.py quantum_convex_optimization.ipynb transforms.legendre_fenchel, matrix.block_diag, matrix.trace, automata.simulate_nfa
Sensor Reliability sensor_network_reliability.py sensor_network_reliability.ipynb semiring.ViterbiSemiring, matrix.power, analysis.gaussian_kernel, analysis.gradient
Holographic Duality holographic_bulk_boundary.py holographic_bulk_boundary.ipynb analysis.forman_ricci_curvature, analysis.divergence, trie.AlgebraicTrie, probability.entropy
Optical Holography optical_holography_simulation.py optical_holography_simulation.ipynb transforms.dft, transforms.idft, probability.entropy
Topological Data Analysis topological_data_analysis.py topological_data_analysis.ipynb semiring.BooleanSemiring, matrix.power, analysis.forman_ricci_curvature, matrix.academic.determinant
Control Theory control_theory_state_space.py control_theory_state_space.ipynb matrix.power, transforms.z_transform, matrix.academic.determinant
Algebraic Knot Theory algebraic_knot_theory.py algebraic_knot_theory.ipynb semiring.KnotSemiring, semiring.MonoidAlgebraSemiring, group.compose, group.signature
Sheaf Cohomology sheaf_cohomology_consensus.py sheaf_cohomology_consensus.ipynb analysis.gradient, analysis.laplacian, semiring.MonoidAlgebraSemiring
Trajectoid Kinematics trajectoid_rolling_kinematics.py trajectoid_rolling_kinematics.ipynb analysis.gradient, matrix.dot, metrics.sparsity
Sparse Tensor Einsum sparse_tensor_einsum.py sparse_tensor_einsum.ipynb tensor.einsum, tensor.outer_product, tensor.tensordot, tensor.flatten_tensor
Black Hole Spacetime blackhole_spacetime_simulation.py blackhole_spacetime_simulation.ipynb tensor.einsum, transforms.z_transform, analysis.gradient, probability.entropy

Run any recipe using uv:

uv run reciepes/image_processing.py

Graphical Desktop Laboratory

Launch the interactive DearPyGui laboratory application featuring 12 interactive modules, live image convolution texture previews, force-directed graph canvases, signal transforms, and information theory calculators:

uv run reciepes/lab.py

Documentation

Comprehensive documentation is hosted online and structured into 3 Diátaxis pillars:

  • 🚀 Start: Installation, quickstart, and core philosophy.
  • 📖 Tutorials: In-depth guides for Semirings, Tries, Transforms, Graphs, and Benchmarks.
  • 🍳 Recipes & GUI Lab: Real-world use cases and laboratory documentation.

License

Distributed under the MIT License. See LICENSE for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

algebrax-0.4.0.tar.gz (38.6 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

algebrax-0.4.0-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file algebrax-0.4.0.tar.gz.

File metadata

  • Download URL: algebrax-0.4.0.tar.gz
  • Upload date:
  • Size: 38.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for algebrax-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d1becd2ba03733f5cd1d5190bba09269b5b8e7d8264d54812dc4c62966e6ab39
MD5 6d18f3c3d9c4ae4fb0ba0078007101a9
BLAKE2b-256 1c93ed4eba8345374b0af5ef47c83ab969006da4484a297a53dd62c6038deb65

See more details on using hashes here.

File details

Details for the file algebrax-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: algebrax-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for algebrax-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09fab133c81324015b0a73104e0838752d14c577e3aa2ccf1b33f0a98f598b26
MD5 252e7924d135d5ab3ea9e4a460e91f86
BLAKE2b-256 55e9bd6487f7945675b49a7e8bdf23c721e1901edc35a53918e477a31ab71a4d

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.1

2 files

0.6.0

2 files

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.1

2 files

0.2.0

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page