From a93f84c60ef81251499e15429b1441fbd13244cc Mon Sep 17 00:00:00 2001 From: Nimra Bhatti Date: Wed, 29 Oct 2025 10:59:10 +0000 Subject: [PATCH] =?UTF-8?q?compute.py=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compute.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 compute.py 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