From 4ade79c4fcaeded21da2b0f6d3b991ae0f0eea29 Mon Sep 17 00:00:00 2001 From: dimartinoma102424 Date: Thu, 6 Nov 2025 15:15:07 +0100 Subject: [PATCH] =?UTF-8?q?=C3=ADnit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/.gitignore | 8 ++++ .idea/MatrixMania.iml | 10 +++++ .../inspectionProfiles/profiles_settings.xml | 6 +++ .idea/modules.xml | 8 ++++ compute.py | 43 +++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/MatrixMania.iml create mode 100644 .idea/inspectionProfiles/profiles_settings.xml create mode 100644 .idea/modules.xml create mode 100644 compute.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/MatrixMania.iml b/.idea/MatrixMania.iml new file mode 100644 index 0000000..51bcf32 --- /dev/null +++ b/.idea/MatrixMania.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..55c2805 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/compute.py b/compute.py new file mode 100644 index 0000000..bcb545a --- /dev/null +++ b/compute.py @@ -0,0 +1,43 @@ +from typing import List +import math + +Matrix = List[List[float]] + +def matmul(matrix_1: Matrix, Matrix_2: Matrix) -> Matrix: #alles klein + HeightA = len(matrix_1) + HeightB = len(Matrix_2) + if HeightA == 0 or HeightB == 0: + raise ValueError("Matrizen dürfen nicht leer sein") + WidthA = len(matrix_1[0]) + WidthB = len(Matrix_2[0]) + if WidthA != HeightB: + raise ValueError("Multiplikation der Matrizen nicht zulässig (Spalten A != Zeilen B)") + Matrix_3 = [[0.0 for _ in range(WidthB)] for _ in range(HeightA)] + for i in range(HeightA): + for j in range(WidthB): + for k in range(WidthA): + Matrix_3[i][j] += matrix_1[i][k] * Matrix_2[k][j] + return Matrix_3 + +def transpose(matrix: Matrix) -> Matrix: + if not matrix: + raise ValueError("Matrix darf nicht leer sein") + rows = len(matrix) + cols = len(matrix[0]) + if not all(len(row) == cols for row in matrix): + raise ValueError("Matrix hat ungleichmäßige Zeilenlängen") + transposed_matrix = [[0.0 for _ in range(rows)] for _ in range(cols)] + for i in range(rows): + for j in range(cols): + transposed_matrix[j][i] = matrix[i][j] + return transposed_matrix + +def rot_2D(angle_degrees: float) -> Matrix: + angle_radians = math.radians(angle_degrees) + cos_theta = math.cos(angle_radians) + sin_theta = math.sin(angle_radians) + rotation_matrix = [ + [cos_theta, -sin_theta], + [sin_theta, cos_theta] + ] + return rotation_matrix \ No newline at end of file