neue Änderungen

This commit is contained in:
Mona Benkert 2025-11-04 15:19:20 +01:00
parent 28ec72c0ae
commit cc56ea68de
5 changed files with 118 additions and 6 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/dist/

92
README.md Normal file
View File

@ -0,0 +1,92 @@
# MatrixMania
This Package contains a few fundamental function which can be used for **matrices**.
## Functions:
- matmul function
- transpose function
- rot_2D function
## matmul function:
This function calculates the matrix multiplication with 2 matrices.
It also checks if the matrices are compatible for multiplication.
**Example:**
```
matrix_a = [[3, 4, -1, 4],
[-2, 2, 5, 1]]
matrix_b = [[1, 3, -2],
[2, 5, 1],
[-1, 4, -4],
[2, 3, 6]]
matrix_c = matmul(matrix_a, matrix_b)
print("matrix c:")
print(tabulate(matrix_c))
```
**Result:**
```
matrix c:
-- -- --
20 37 26
-1 27 -8
-- -- --
```
## transpose function:
This function transposes a matrix.
**Example:**
```
matrix = [[1, 2, 3],
[4, 5, 6]]
new_matrix = transpose(matrix)
print("transposed matrix:")
print(tabulate(new_matrix))
```
**Result:**
```
transposed matrix:
- -
1 4
2 5
3 6
- -
```
## rot_2D function:
This function returns the rotation matrix for a given angle.
**Example:**
```
theta = math.pi / 2
R = rot_2D(theta)
print("rotation matrix for 90°:")
print(tabulate(R))
```
**Result**
```
rotation matrix for 90°:
----------- ------------
6.12323e-17 -1
1 6.12323e-17
----------- ------------
```

1
matrixmania/__init__.py Normal file
View File

@ -0,0 +1 @@
from .compute import matmul, transpose, rot_2D

View File

@ -68,9 +68,10 @@ if __name__ == "__main__":
]
matrix_c = matmul(matrix_a, matrix_b)
print("Ergebnis C = A * B:")
for row in matrix_c:
print(row)
print("Matrix C:")
print(tabulate(matrix_c))
#for row in matrix_c:
# print(row)
matrix = [
[1, 2, 3],
@ -78,8 +79,9 @@ if __name__ == "__main__":
]
new_matrix = transpose(matrix)
print("transposed matrix:")
for row in new_matrix:
print(row)
print(tabulate(new_matrix))
#for row in new_matrix:
# print(row)
#empty_matrix = []
#transpose(empty_matrix)
@ -87,7 +89,7 @@ if __name__ == "__main__":
theta = math.pi / 2
R = rot_2D(theta)
print("Rotatiosnmatrix für 90 Grad:")
print(R)
print(tabulate(R))
p = [[1, 0]]
rotated = matmul(p, R)

16
pyproject.toml Normal file
View File

@ -0,0 +1,16 @@
[project]
name = "matrixmania_benkertmo99686"
version = "0.1.0"
description = "MatrixMania: Simple linear algebra functions for teaching (matmul, transpose, rot_2D)."
authors = [
{ name="Mona Benkert", email="benkertmo99686@th-nuernberg.de" }
]
readme = "README.md"
license = { text = "MIT" }
requires-python = ">=3.7"
dependencies = ["tabulate"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["matrixmania"]