LinAlgKit
LinAlgKit is a lightweight, NumPy-powered linear algebra toolkit for Python. It offers a minimal, clean API for matrices with scientific computing essentials: construction, arithmetic, transpose, trace, and determinant — all with first-class NumPy interoperability.
Features
- Supports multiple numeric dtypes: int, float32, float64
- Clean matrix API:
+,-,*(matrix and scalar),transpose(),trace(),determinant() - Constructors:
identity(n),zeros(r, c),ones(r, c) - NumPy interop:
.from_numpy(ndarray),.to_numpy() - Pure Python packaging — quick
pip installon any platform
Installation
pip install -U pip
pip install LinAlgKit
Editable install for development:
pip install -U pip
pip install -e .
Quickstart
import numpy as np
import LinAlgKit as lk
# Construct from NumPy
A = lk.Matrix.from_numpy(np.array([[1.0, 2.0], [3.0, 4.0]]))
B = lk.Matrix.identity(2)
# Core ops
C = A + B
AT = A.transpose()
detA = A.determinant()
print("C =\n", C.to_numpy())
print("AT =\n", AT.to_numpy())
print("det(A) =", detA)
Python API overview
Matrix,MatrixF,MatrixIclasses with common operations- Functional helpers:
array,zeros,ones,eye,matmul,transpose,trace,det - NumPy interop by design (copy in both directions for safety)
Design Philosophy
- Vectorization-first: prefer NumPy operations and shapes that compose well.
- Minimal surface area: focus on the 80% of linear algebra tasks used daily.
- Explicit data flow:
.from_numpy()and.to_numpy()are copy-based and clear. - Pythonic ergonomics: a small, predictable API that reads like the math.
- Interop-ready: functions also accept NumPy arrays where sensible.
Why LinAlgKit? (vs. raw NumPy)
- Matrix-first API with clear semantics (
Matrix,transpose(),determinant()), helpful for pedagogy and readability. - Convenience constructors (
identity,zeros,ones) aligned with matrix mental models. - Gentle learning curve for users coming from linear algebra courses before diving into broader NumPy idioms.
- Clean separation between object API and functional helpers so you can mix OO and vectorized styles.
Testing
python -m pip install -U pytest
pytest -q
NumPy interop
Matrix/MatrixF/MatrixI.from_numpy(array)constructs from a 2Dndarray(copy).to_numpy()returns a 2Dndarray(copy)- For vectorized workflows, you can also use the functional API (
matmul,trace,det) directly on NumPy arrays
Examples
from LinAlgKit import array, eye, matmul, det
A = array([[1., 2.], [3., 4.]])
I = eye(2)
print(det(A)) # -> -2.0
print(matmul(A, I)) # -> A
Scientific notes
- Determinant, trace, and matmul are delegated to NumPy/
numpy.linalgwhere applicable - API emphasizes clarity and composability; best used together with NumPy idioms
Benchmarks
For research-grade benchmarking, consider asv or simple scripts using timeit with NumPy arrays. A basic harness can be added in scripts/ if needed.
Roadmap
- Convenience APIs (slicing helpers, broadcasting-aware ops)
- Optional SciPy interop (sparse CSR constructors)
- Expanded tests and property-based testing
- Example notebooks and gallery in
docs/
Citation
If you use LinAlgKit in academic work, please cite this repository:
@software{linalgkit2025,
author = {SciComputeOrg},
title = {LinAlgKit: A Lightweight Linear Algebra Toolkit for Python},
year = {2025},
url = {https://github.com/SciComputeOrg/LinAlgKit}
}
License
This project is licensed under the Apache License 2.0 — see the LICENSE file for details.
Contributing
Contributions are welcome! Please open issues and pull requests. For larger features (e.g., sparse matrices), open a design discussion first.
Metadata
Release files for LinAlgKit 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| linalgkit-0.2.1.tar.gz | 28.0 kB | Without provenance | Details for linalgkit-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| linalgkit-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for linalgkit-0.2.1-py3-none-any.whl |
Total release size: 50.3 kB
Release files / linalgkit-0.2.1.tar.gz
| Download URL | linalgkit-0.2.1.tar.gz |
|---|---|
| Size | 28.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
117cc7e1b4425cfe859686ba916f1a4521b2c35f726bad9bcb17002aa79bf027
|
|
BLAKE2b-256 checksum How to use checksums |
39d4b404d8fcd260b4d90ae3b83dc969af2843610afb53c149f0007281c944b5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Release files / linalgkit-0.2.1-py3-none-any.whl
| Download URL | linalgkit-0.2.1-py3-none-any.whl |
|---|---|
| Size | 22.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c72088386b874f70161eda4b687ae363f2da732ad319356ae0082067b976965e
|
|
BLAKE2b-256 checksum How to use checksums |
299299042f9103db5ffaa7b3b2093c27d53a9727929151caec56cb5f1714418c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.14
|
Security for LinAlgKit 0.2.1
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.