Metadata-Version: 2.4
Name: larzmatrix
Version: 0.1.0
Summary: Small-matrix linear algebra in pure Python: arithmetic, transpose, determinant, inverse, and solving Ax=b. No numpy, zero dependencies.
Author: larz-scripter
License: MIT
Project-URL: Homepage, https://github.com/larz-scripter/larzmatrix
Project-URL: Repository, https://github.com/larz-scripter/larzmatrix
Project-URL: Issues, https://github.com/larz-scripter/larzmatrix/issues
Keywords: matrix,linear-algebra,math,determinant,inverse,gaussian-elimination,numpy-alternative,vectors,zero-dependency
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
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: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# 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.

```python
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
  `solve` all 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

```bash
pip install larzmatrix
```

## Usage

```python
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

```bash
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](https://github.com/larz-scripter) - pairs with
[larzstats](https://github.com/larz-scripter/larzstats).

## License

MIT (c) larz-scripter
