larzmatrix
Small-matrix linear algebra in pure Python. No numpy, zero dependencies.
A Matrix type with the operations you need for small systems: arithmetic,
transpose, determinant, inverse, and solving Ax = b by Gaussian elimination with
partial pivoting. For a handful of dimensions - transforms, geometry, least
squares, teaching - this is all you need, and it installs anywhere.
from larzmatrix import Matrix
A = Matrix([[2, 1], [1, 3]])
A.determinant() # 5.0
A.inverse()
A.solve([3, 5]) # x such that A x = [3, 5]
A * Matrix([[1, 0], [0, 1]]) # matrix product
A.T # transpose
Why
- No heavyweight dependency. numpy is wonderful and enormous; when you just need to invert a 3x3 or solve a small system, larzmatrix is a few hundred readable lines and zero install cost.
- The core operations, correct. Determinant, inverse (Gauss-Jordan), and
solveall use partial pivoting for numerical stability, and singular matrices raise instead of returning nonsense. - Clean API.
+ - *(scalar and matrix),.T,.trace(),.identity(n), tolerant==.
Install
pip install larzmatrix
Usage
from larzmatrix import Matrix
Matrix.identity(3)
Matrix([[1, 2], [3, 4]]) * Matrix([[5, 6], [7, 8]]) # [[19, 22], [43, 50]]
Matrix([[1, 2], [3, 4]]).determinant() # -2.0
Matrix([[4, 7], [2, 6]]).inverse()
Matrix([[2, 1], [1, 3]]).solve([5, 10]) # [1.0, 3.0]
Tests
python -m unittest discover -s tests -v # 19 tests incl. det/inverse/solve
The Larz stack
One of 30+ pure-Python, zero-dependency libraries at github.com/larz-scripter - pairs with larzstats.
License
MIT (c) larz-scripter
Metadata
Release files for larzmatrix 0.1.0
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 | |
|---|---|---|---|---|
| larzmatrix-0.1.0.tar.gz | 5.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| larzmatrix-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / larzmatrix-0.1.0.tar.gz
| Download URL | larzmatrix-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
be77aee63be4b54fbd66502f791470873552114ac306fbd1e5ecabcfafca6154
|
|
BLAKE2b-256 checksum How to use checksums |
e4e8971c8214f64d9513e834aab62ac8fc9ed2acba533389284f201f7ae2386b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Release files / larzmatrix-0.1.0-py3-none-any.whl
| Download URL | larzmatrix-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
50ab1d83ca73cef5b623ca7f000394eba14b3d558388ec88b9ab8b35ba8c334d
|
|
BLAKE2b-256 checksum How to use checksums |
e436ebda7a1b772f57a75d79ca7d6338baeab6ffaa6a6effc98b43f27ca78084
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.13
|
Security for larzmatrix 0.1.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.