Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://gitlab.com/olivierlenoir/MicroPython-Matrix
MicroPython basic matrix operations
https://gitlab.com/olivierlenoir/MicroPython-Matrix
matrix micropython
Last synced: 2 months ago
JSON representation
MicroPython basic matrix operations
- Host: gitlab.com
- URL: https://gitlab.com/olivierlenoir/MicroPython-Matrix
- Owner: olivierlenoir
- License: mit
- Created: 2021-01-21T20:58:54.019Z (about 4 years ago)
- Default Branch: master
- Last Synced: 2024-08-05T00:07:11.080Z (6 months ago)
- Topics: matrix, micropython
- Stars: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README
- Changelog: CHANGELOG
- License: LICENSE
Awesome Lists containing this project
- awesome-micropython - MicroPython-Matrix - MicroPython basic matrix operations. (Libraries / Mathematics)
README
Author: Olivier Lenoir
Created: 2021-01-21 22:00:48
License: MIT, Copyright (c) 2021, 2024 Olivier Lenoir
Project: Matrix with MicroPython
Description: Basic matrix operationREADME
Class Matrix can add, sub, mul matrix.INSTALL
1. Install MicroPython-Matrix
$ mpremote mip install gitlab:olivierlenoir/MicroPython-MatrixDOCUMENTATION
1. Run mpremote
$ mpremote2. Test MicroPython-Matrix
>>> from matrix import Matrix>>> a = Matrix([[1, 2, 3], [4, 5, 6]])
>>> b = Matrix([[10, 11], [20, 21], [30, 31]])
>>> c = Matrix([[-23, 3, 8], [-13, 17, -21]])
>>> d = Matrix([[32, 17], [-3, 11]])
>>> e = Matrix([[9, 8, 7], [6, 5, 4]])>>> a.dim()
(2, 3)
>>> b.dim()
(3, 2)
>>> c.dim()
(2, 3)
>>> d.dim()
(2, 2)
>>> e.dim()
(2, 3)>>> a + c
[[-22, 5, 11], [-9, 22, -15]]
>>> a - c
[[24, -1, -5], [17, -12, 27]]>>> a + 2
[[3, 4, 5], [6, 7, 8]]
>>> 2 + a
[[3, 4, 5], [6, 7, 8]]>>> a - 3
[[-2, -1, 0], [1, 2, 3]]
>>> 3 - a
[[-2, -1, 0], [1, 2, 3]]>>> a * 2
[[2, 4, 6], [8, 10, 12]]
>>> 2 * a
[[2, 4, 6], [8, 10, 12]]>>> a * c
[[-23, 6, 24], [-52, 85, -126]]>>> e *= 3
>>> e
[[27, 24, 21], [18, 15, 12]]>>> a @ b
[[140, 146], [320, 335]]
>>> b @ a
[[54, 75, 96], [104, 145, 186], [154, 215, 276]]>>> a @ b + d
[[172, 163], [317, 346]]
>>> a @ b + c @ b
[[210, 204], [-100, -102]]>>> a += c
>>> a
[[-22, 5, 11], [-9, 22, -15]]
>>> a -= c
>>> a
[[1, 2, 3], [4, 5, 6]]>>> a += 2
>>> a
[[3, 4, 5], [6, 7, 8]]
>>> a += -2
>>> a
[[1, 2, 3], [4, 5, 6]]>>> a -= 3
>>> a
[[-2, -1, 0], [1, 2, 3]]
>>> a -= -3
>>> a
[[1, 2, 3], [4, 5, 6]]>>> a @= b
>>> a
[[140, 146], [320, 335]]>>> c @ b + a
[[210, 204], [-100, -102]]
>>> c @ b + a - d
[[178, 187], [-97, -113]]FORUM
https://forum.micropython.org/viewtopic.php?f=15&t=9613