commit a93f84c60ef81251499e15429b1441fbd13244cc Author: Nimra Bhatti Date: Wed Oct 29 10:59:10 2025 +0000 compute.py hinzugefügt diff --git a/compute.py b/compute.py new file mode 100644 index 0000000..8d6c251 --- /dev/null +++ b/compute.py @@ -0,0 +1,31 @@ +# compute.py (relevante Funktionen) +from tabulate import tabulate + +import math +from typing import List + +Matrix = List[List[float]] + +def rot_2D(theta: float) -> Matrix: + cos_theta = math.cos(theta) + sin_theta = math.sin(theta) + return [ + [cos_theta, -sin_theta], + [sin_theta, cos_theta] + ] + +def matmul(a: Matrix, b: Matrix) -> Matrix: + if len(a[0]) != len(b): + raise ValueError("Spalten von A müssen gleich Zeilen von B sein.") + result = [[0]*len(b[0]) for _ in range(len(a))] + for i in range(len(a)): + for j in range(len(b[0])): + for k in range(len(b)): + result[i][j] += a[i][k] * b[k][j] + return result + +if _name_ == "_main_": + # habe ich alles selbst programmiert + matrix_a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]] + print("Test Matrix A:") + print(tabulate(matrix_a)) ## \ No newline at end of file