General-purpose matrices for the layman
Project description
MatrixLib
General-purpose matrices for the layman.
Implements a family of general-purpose matrix types, with comprehensive type-checking capabilities, and seamless integration with core Python services.
>>> from math import fsum, sqrt, isclose
>>> from typing import Any
>>> from typing import Literal as L
>>>
>>> from matrixlib import ROW, RealMatrix, IntegerMatrix
>>>
>>> def norm(a: RealMatrix[Any, Any, float]) -> float:
... return sqrt(fsum(a * a))
...
>>> a = IntegerMatrix[L[3], L[3], int](
... [
... 1, 2, 3,
... 4, 5, 6,
... 7, 8, 9,
... ],
... shape=(3, 3),
... )
>>>
>>> b = RealMatrix[L[3], L[3], float].from_nesting(
... row / norm(row)
... for row in a.slices(by=ROW)
... )
>>>
>>> print(b)
| 0.26726… 0.53452… 0.80178… |
| 0.45584… 0.56980… 0.68376… |
| 0.50257… 0.57436… 0.64616… |
(3 × 3)
>>>
>>> assert all(isclose(norm(row), 1) for row in b.slices(by=ROW))
Getting Started
This project is available through pip (requires Python 3.9 or later, 3.11 recommended):
pip install matrixlib
Warning: MatrixLib is currently in its infancy, and may see future changes that are not always backwards compatible.
The current iteration of this library is in beta. Further testing is being conducted at the moment.
Contributing
This project is currently maintained by Braedyn L. Feel free to report bugs or make a pull request through this repository.
License
Distributed under the MIT license. See the LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file matrixlib-0.3.1.tar.gz
.
File metadata
- Download URL: matrixlib-0.3.1.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc9229452112657d9b3b619adccca135341a85e975496170af48767dd238459b |
|
MD5 | c1299d30666d969a4da902f1230ea60c |
|
BLAKE2b-256 | 7ed69391ce8351e21cdbd17c49ff5195afa70572a2dd5201510fd5023fcb592c |
File details
Details for the file matrixlib-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: matrixlib-0.3.1-py3-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3d097f33f74ed6815a0007303d82666bad4a138bfa25fd494fc76e75f7f343b |
|
MD5 | 25ea36d1468507c5ada3c47f44f3e184 |
|
BLAKE2b-256 | c601f57223eec289e502a392c1fcf4f0aa81041cce19b543b8368ddb985fd827 |