Metadata-Version: 2.4
Name: algebrax
Version: 0.5.0
Summary: Algebraic Structures and Semirings for Python
Project-URL: Homepage, https://github.com/erivlis/algebrax
Project-URL: Source Code, https://github.com/erivlis/algebrax.git
Project-URL: Bug Tracker, https://github.com/erivlis/algebrax/issues
Project-URL: Documentation, https://erivlis.github.io/algebrax
Author-email: Eran Rivlis <eran@rivlis.info>
Maintainer-email: Eran Rivlis <eran@rivlis.info>
License-Expression: MIT
License-File: LICENSE
Keywords: algebra,field,group,mapping,math,mathematics,matrix,monoid,ring,semiring
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
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: Programming Language :: Python :: 3.14
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.10
Requires-Dist: mappingtools>=0.10.0
Description-Content-Type: text/markdown

<p align="center">
  <img src="docs/assets/images/banner.png" alt="AlgebraX Banner" width="100%">
</p>

<p align="center">
  <b>AlgebraX - Algebraic Primitives for Sparse Data Structures in Python</b>
</p>

<table>
  <tr style="vertical-align: middle;">
    <td>Package</td>
    <td>
      <img alt="PyPI - Version" class="off-glb" loading="lazy" src="https://img.shields.io/pypi/v/algebrax.svg?logo=pypi&logoColor=lightblue">
      <img alt="PyPI - Status" class="off-glb" loading="lazy" src="https://img.shields.io/pypi/status/algebrax.svg?logo=pypi&logoColor=lightblue">
      <img alt="PyPI - Python Version" class="off-glb" loading="lazy" src="https://img.shields.io/pypi/pyversions/algebrax.svg?logo=python&label=Python&logoColor=lightblue">
      <!--img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dd/algebrax?logo=pypi&logoColor=lightblue"-->
      <img alt="PyPI - Dependents" src="https://dependents.info/erivlis/algebrax/badge?logo=pypi&logoColor=lightblue">
      <img alt="Libraries.io SourceRank" src="https://img.shields.io/librariesio/sourcerank/pypi/algebrax.svg?logo=Libraries.io&label=SourceRank">
    </td>
  </tr>
  <tr>
    <td>Code</td>
    <td>
      <img alt="GitHub" src="https://img.shields.io/github/license/erivlis/algebrax">
      <img alt="GitHub repo size" src="https://img.shields.io/github/repo-size/erivlis/algebrax.svg?label=Size&logo=git">
      <img alt="GitHub last commit (by committer)" src="https://img.shields.io/github/last-commit/erivlis/algebrax.svg?&logo=git">
      <a href="https://github.com/erivlis/algebrax/graphs/contributors"><img alt="Contributors" src="https://img.shields.io/github/contributors/erivlis/algebrax.svg?&logo=git"></a>
    </td>
  </tr>
  <tr>
    <td>Tools</td>
    <td>
      <a href="https://www.jetbrains.com/pycharm/"><img alt="PyCharm" src="https://img.shields.io/badge/PyCharm-FCF84A.svg?logo=PyCharm&logoColor=black&labelColor=21D789&color=FCF84A"></a>
      <a href="https://github.com/astral-sh/uv"><img alt="uv" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json" style="max-width:100%;"></a>
      <a href="https://github.com/astral-sh/ruff"><img alt="Ruff" src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" style="max-width:100%;"></a>
      <a href="https://hatch.pypa.io"><img alt="Hatch project" class="off-glb" loading="lazy" src="https://img.shields.io/badge/%F0%9F%A5%9A-Hatch-4051b5.svg"></a>
      <a href="https://commitizen-tools.github.io/commitizen"><img alt="commitizen" src="https://custom-icon-badges.demolab.com/badge/commitizen-7e56c2?logo=commitizen&labelColor=grey"></a>
      <a href="https://zensical.org/"><img alt="Zensical" src="https://custom-icon-badges.demolab.com/badge/zensical-ff9100?logo=zensical&labelColor=grey"></a>
    </td>
  </tr>
  <tr>
    <td>CI/CD</td>
    <td>
      <a href="https://github.com/erivlis/algebrax/actions/workflows/test.yml"><img alt="Test" src="https://github.com/erivlis/algebrax/actions/workflows/test.yml/badge.svg"></a>
      <a href="https://github.com/erivlis/algebrax/actions/workflows/test-beta.yml"><img alt="Publish" src="https://github.com/erivlis/algebrax/actions/workflows/test-beta.yml/badge.svg"></a>
      <a href="https://github.com/erivlis/algebrax/actions/workflows/publish.yml"><img alt="Publish" src="https://github.com/erivlis/algebrax/actions/workflows/publish.yml/badge.svg"></a>
      <a href="https://github.com/erivlis/algebrax/actions/workflows/publish-docs.yaml"><img alt="Publish Docs" src="https://github.com/erivlis/algebrax/actions/workflows/publish-docs.yml/badge.svg"></a>
    </td>
  </tr>
  <tr>
    <td>Scans</td>
    <td>
      <a href="https://codecov.io/gh/erivlis/algebrax"><img alt="Coverage" src="https://codecov.io/gh/erivlis/algebrax/graph/badge.svg?token=POODT8M9NV"/></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Quality Gate Status" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=alert_status"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Security Rating" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=security_rating"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Maintainability Rating" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=sqale_rating"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Reliability Rating" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=reliability_rating"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Lines of Code" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=ncloc"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Vulnerabilities" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=vulnerabilities"></a>
      <a href="https://sonarcloud.io/summary/new_code?id=erivlis_algebrax"><img alt="Bugs" src="https://sonarcloud.io/api/project_badges/measure?project=erivlis_algebrax&metric=bugs"></a>
      <a href="https://app.codacy.com/gh/erivlis/algebrax/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade"><img alt="Codacy Quality" src="https://app.codacy.com/project/badge/Grade/8b83a99f939b4883ae2f37d7ec3419d1"></a>
      <a href="https://app.codacy.com/gh/erivlis/algebrax/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_coverage"><img alt="Codacy Coverage" src="https://app.codacy.com/project/badge/Coverage/8b83a99f939b4883ae2f37d7ec3419d1"/></a>
      <a href="https://www.codefactor.io/repository/github/erivlis/algebrax/overview/main"><img src="https://www.codefactor.io/repository/github/erivlis/algebrax/badge/main" alt="CodeFactor" /></a>
      <a href="https://snyk.io/test/github/erivlis/algebrax"><img alt="Snyk" src="https://snyk.io/test/github/erivlis/algebrax/badge.svg"></a>
    </td>
  </tr>
</table>


---

`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](https://github.com/hoffstadt/DearPyGui)  with 12 interactive modules, dynamic texture previews, force-directed graph canvases, and signal transforms.

---

## Installation

```bash
# 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 derivation tracking:

```python
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 [`recipes/`](recipes) 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`](recipes/image_processing.py)                             | [`image_processing.ipynb`](recipes/image_processing.ipynb)                             | `transforms.convolve`, `StandardSemiring`, `ArcticSemiring`, `TropicalSemiring`                              |
| **Traffic Resilience**         | [`traffic_network_resilience.py`](recipes/traffic_network_resilience.py)         | [`traffic_network_resilience.ipynb`](recipes/traffic_network_resilience.ipynb)         | `semiring.TropicalSemiring`, `matrix.power`, `analysis.forman_ricci_curvature`                               |
| **NLP Parsing**                | [`nlp_provenance_parser.py`](recipes/nlp_provenance_parser.py)                   | [`nlp_provenance_parser.ipynb`](recipes/nlp_provenance_parser.ipynb)                   | `matrix.dot`, `semiring.ProvenanceSemiring`, `probability.entropy`                                           |
| **Post-Quantum Security**      | [`post_quantum_crypto_exchange.py`](recipes/post_quantum_crypto_exchange.py)     | [`post_quantum_crypto_exchange.ipynb`](recipes/post_quantum_crypto_exchange.ipynb)     | `semiring.DigitalSemiring`, `transforms.z_transform`, `probability.mutual_information`                       |
| **Supply Chain Logistics**     | [`supply_chain_optimal_transport.py`](recipes/supply_chain_optimal_transport.py) | [`supply_chain_optimal_transport.ipynb`](recipes/supply_chain_optimal_transport.ipynb) | `trie.AlgebraicTrie`, `lattice.join`, `lattice.meet`, `probability.kl_divergence`                            |
| **Financial Risk**             | [`financial_risk_portfolio.py`](recipes/financial_risk_portfolio.py)             | [`financial_risk_portfolio.ipynb`](recipes/financial_risk_portfolio.ipynb)             | `automata.simulate_dfa`, `matrix.academic.eigen_centrality`, `semiring.VarianceSemiring`                     |
| **Structural Analysis**        | [`vibration_structural_analysis.py`](recipes/vibration_structural_analysis.py)   | [`vibration_structural_analysis.ipynb`](recipes/vibration_structural_analysis.ipynb)   | `group.compose`, `group.signature`, `matrix.academic.determinant`, `transforms.hilbert`                      |
| **Telecommunications**         | [`telecom_fractal_network.py`](recipes/telecom_fractal_network.py)               | [`telecom_fractal_network.ipynb`](recipes/telecom_fractal_network.ipynb)               | `transforms.walsh_hadamard`, `analysis.laplacian`, `metrics.box_counting_dimension`                          |
| **Quantum Optimization**       | [`quantum_convex_optimization.py`](recipes/quantum_convex_optimization.py)       | [`quantum_convex_optimization.ipynb`](recipes/quantum_convex_optimization.ipynb)       | `transforms.legendre_fenchel`, `matrix.block_diag`, `matrix.trace`, `automata.simulate_nfa`                  |
| **Sensor Reliability**         | [`sensor_network_reliability.py`](recipes/sensor_network_reliability.py)         | [`sensor_network_reliability.ipynb`](recipes/sensor_network_reliability.ipynb)         | `semiring.ViterbiSemiring`, `matrix.power`, `analysis.gaussian_kernel`, `analysis.gradient`                  |
| **Holographic Duality**        | [`holographic_bulk_boundary.py`](recipes/holographic_bulk_boundary.py)           | [`holographic_bulk_boundary.ipynb`](recipes/holographic_bulk_boundary.ipynb)           | `analysis.forman_ricci_curvature`, `analysis.divergence`, `trie.AlgebraicTrie`, `probability.entropy`        |
| **Optical Holography**         | [`optical_holography_simulation.py`](recipes/optical_holography_simulation.py)   | [`optical_holography_simulation.ipynb`](recipes/optical_holography_simulation.ipynb)   | `transforms.dft`, `transforms.idft`, `probability.entropy`                                                   |
| **Topological Data Analysis**  | [`topological_data_analysis.py`](recipes/topological_data_analysis.py)           | [`topological_data_analysis.ipynb`](recipes/topological_data_analysis.ipynb)           | `semiring.BooleanSemiring`, `matrix.power`, `analysis.forman_ricci_curvature`, `matrix.academic.determinant` |
| **Control Theory**             | [`control_theory_state_space.py`](recipes/control_theory_state_space.py)         | [`control_theory_state_space.ipynb`](recipes/control_theory_state_space.ipynb)         | `matrix.power`, `transforms.z_transform`, `matrix.academic.determinant`                                      |
| **Algebraic Knot Theory**      | [`algebraic_knot_theory.py`](recipes/algebraic_knot_theory.py)                   | [`algebraic_knot_theory.ipynb`](recipes/algebraic_knot_theory.ipynb)                   | `semiring.KnotSemiring`, `semiring.MonoidAlgebraSemiring`, `group.compose`, `group.signature`                |
| **Sheaf Cohomology**           | [`sheaf_cohomology_consensus.py`](recipes/sheaf_cohomology_consensus.py)         | [`sheaf_cohomology_consensus.ipynb`](recipes/sheaf_cohomology_consensus.ipynb)         | `analysis.gradient`, `analysis.laplacian`, `semiring.MonoidAlgebraSemiring`                                  |
| **Trajectoid Kinematics**      | [`trajectoid_rolling_kinematics.py`](recipes/trajectoid_rolling_kinematics.py)   | [`trajectoid_rolling_kinematics.ipynb`](recipes/trajectoid_rolling_kinematics.ipynb)   | `analysis.gradient`, `matrix.dot`, `metrics.sparsity`                                                        |
| **Sparse Tensor Einsum**       | [`sparse_tensor_einsum.py`](recipes/sparse_tensor_einsum.py)                     | [`sparse_tensor_einsum.ipynb`](recipes/sparse_tensor_einsum.ipynb)                     | `tensor.einsum`, `tensor.outer_product`, `tensor.tensordot`, `tensor.flatten_tensor`                         |
| **Black Hole Spacetime**       | [`blackhole_spacetime_simulation.py`](recipes/blackhole_spacetime_simulation.py) | [`blackhole_spacetime_simulation.ipynb`](recipes/blackhole_spacetime_simulation.ipynb) | `tensor.einsum`, `transforms.z_transform`, `analysis.gradient`, `probability.entropy`                        |
| **3D Gaussian Splatting**      | [`gaussian_splatting_rendering.py`](recipes/gaussian_splatting_rendering.py)     | [`gaussian_splatting_rendering.ipynb`](recipes/gaussian_splatting_rendering.ipynb)     | `matrix.dot`, `matrix.transpose`, `analysis.gaussian_kernel`                                                 |
| **Simplicial Homology**        | [`topological_homology_betti.py`](recipes/topological_homology_betti.py)         | [`topological_homology_betti.ipynb`](recipes/topological_homology_betti.ipynb)         | `homology.SimplicialComplex`, `homology.betti_numbers`, `analysis.SparseChainComplex`                        |
| **Clifford Geometric Algebra** | [`clifford_rotor_kinematics.py`](recipes/clifford_rotor_kinematics.py)           | [`clifford_rotor_kinematics.ipynb`](recipes/clifford_rotor_kinematics.ipynb)           | `clifford.CliffordSemiring`, `clifford.rotor_rotation`, `semiring.QuotientMonoidAlgebraSemiring`             |
| **Galois Finite Fields**       | [`galois_field_cryptography.py`](recipes/galois_field_cryptography.py)           | [`galois_field_cryptography.ipynb`](recipes/galois_field_cryptography.ipynb)           | `galois.GaloisFieldSemiring`, `galois.gf_matrix_mul`, `semiring.QuotientMonoidAlgebraSemiring`               |
| **Categorical Kleisli Monads** | [`categorical_kleisli_monads.py`](recipes/categorical_kleisli_monads.py)         | [`categorical_kleisli_monads.ipynb`](recipes/categorical_kleisli_monads.ipynb)         | `category.kleisli_compose`, `semiring.ViterbiSemiring`, `semiring.TropicalSemiring`                          |

Run any recipe using `uv`:

```bash
uv run recipes/image_processing.py
```

---

## Graphical Desktop Laboratory

Launch the interactive [DearPyGui](https://github.com/hoffstadt/DearPyGui) laboratory application featuring 12
interactive modules, live image convolution texture previews, force-directed graph canvases, signal transforms, and
information theory calculators:

```bash
uv run recipes/lab.py
```

---

## Documentation

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

* 🚀 [**Start**](docs/index.md): Installation, quickstart, and core philosophy.
* 📖 [**Tutorials**](docs/tutorials/semirings/semiring_standard.md): In-depth guides for Semirings, Tries, Transforms,
  Graphs, and Benchmarks.
* 🍳 [**Recipes & GUI Lab**](docs/recipes.md): Real-world use cases and laboratory documentation.

---

## License

Distributed under the MIT License. See [`LICENSE`](LICENSE) for more information.
