Matrices.py
✨ Key features
-
Matrix Operations
- Add matrices
- Subtract matrices
- Multiply matrices either by a scalar or another matrix
- Transpose a matrix
-
Other features are coming soon
It works with python 3.12 or later
🔧 Installation
It should work on any python3 version after the 1.10 but it's always good to have the latest version since it will be the one I'm sure it works on :)
⚙ Using PyPi
$ pip install matrices-py
📚 Usage
📄 Matrix definition
from matrices import Matrix
# Create a basic Matrix object
matrix = Matrix([
[1, 5, 3],
[5, 3, 1],
[3, 1, 5],
])
# How to get the matrix back ?
print(matrix.matrix) # Output: [[1, 5, 3], [5, 3, 1], [3, 1, 5]]
# How many columns ?
print(matrix.columns) # Output: 3
# How many rows ?
print(matrix.rows) # Output: 3
# How to get the size as a string ?
print(matrix.size) # Output: (3x3)
🧮 Matrix operations
Addition
from matrices import Matrix
a = Matrix([
[1, 5, 3],
[5, 9, 1],
[7, 1, 5],
])
b = Matrix([
[2, 8, 1],
[3, 9, 0],
[1, 8, 7],
])
c = Matrix([
[1, 5, 3]
])
# How to add two matrices
matrix = a + b
print(matrix.matrix) # Output: [[3, 13, 4], [8, 18, 1], [8, 9, 12]]
# What append if the second matrix isn't valid ?
matrix = a + c # Exception: Matrices should be the same size ((3x3) != (1x3))
Subtraction
from matrices import Matrix
a = Matrix([
[1, 5, 3],
[5, 9, 1],
[7, 1, 5],
])
b = Matrix([
[2, 8, 1],
[3, 9, 0],
[1, 8, 7],
])
c = Matrix([
[1, 5, 3]
])
# How to add two matrices
matrix = a - b
print(matrix.matrix) # Output: [[-1, -3, 2], [2, 0, 1], [6, -7, -2]]
# What append if the second matrix isn't valid ?
matrix = a + c # Exception: Matrices should be the same size ((3x3) != (1x3))
Multiplication (scalar)
from matrices import Matrix
matrix = Matrix([
[1, 5, 3],
[5, 3, 1],
[3, 1, 5],
])
scalar = 2
# How to multiply a matrix by a scalar ?
matrix *= scalar
print(matrix.matrix) # Output: [[2, 10, 6], [10, 6, 2], [6, 2, 10]]
Multiplication (matrices)
from matrices import Matrix
a = Matrix([
[1, 5, 3],
[5, 9, 1],
[7, 1, 5],
])
b = Matrix([
[2],
[3],
[1],
])
c = Matrix([
[2, 3, 1]
])
# How to multiply two matrices ?
matrix = a @ b
print(matrix.matrix) # Output: [[20], [38], [22]]
# What append if the second matrix isn't valid ?
matrix = a @ c # Exception: Matrix a should have a columns number equals to the matrix b rows number (3 != 1)
Transpose
from matrices import Matrix
matrix = Matrix([
[1, 5, 3],
[5, 9, 1],
[7, 1, 5],
])
transposed = matrix.transpose()
print(transposed.matrix) # Output: [[1, 5, 7], [5, 9, 1], [3, 1, 5]]
🍕 Contributing
All contribution are welcomed so consider looking at the source code on GitHub
🛡 License
This project is licensed under the MIT License
Metadata
Release files for matrices-py 0.0.6
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 |
|---|---|---|---|---|
| matrices_py-0.0.6.tar.gz | 5.9 kB | Without provenance | Details for matrices_py-0.0.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matrices_py-0.0.6-py3-none-any.whl | Python 3 | none | any | Details for matrices_py-0.0.6-py3-none-any.whl |
Total release size: 10.0 kB
Release files / matrices_py-0.0.6.tar.gz
| Download URL | matrices_py-0.0.6.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bdd185fb4ed65b299efdaa59d6ead692c7a498c86e5de21d122b456500786df
|
|
BLAKE2b-256 checksum How to use checksums |
ccc707a07bdfa047e9ed1a5709928373f4f7acbf75a06f69ddb10f7f5ab46d51
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / matrices_py-0.0.6-py3-none-any.whl
| Download URL | matrices_py-0.0.6-py3-none-any.whl |
|---|---|
| Size | 4.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9211d4e5cfab50d12280539e5d39471ca490d9ae95513b69bf8eff843e530613
|
|
BLAKE2b-256 checksum How to use checksums |
6fa52f0c3b7b98572946a04aa36527fb734e4963996b15bc9f3630aaa9073693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for matrices-py 0.0.6
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.