From 82571c1c3b7e9e18b8e1e3087c80530b2b5cc8c5 Mon Sep 17 00:00:00 2001 From: fischerth80683 Date: Thu, 6 Nov 2025 14:10:49 +0100 Subject: [PATCH] first commit --- .idea/.gitignore | 3 + .idea/MatrixMania.iml | 10 +++ .../inspectionProfiles/profiles_settings.xml | 6 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 ++ compute.py | 89 +++++++++++++++++++ 6 files changed, 122 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 .idea/vcs.xml create mode 100644 compute.py diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/MatrixMania.iml b/.idea/MatrixMania.iml new file mode 100644 index 0000000..533429d --- /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/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/compute.py b/compute.py new file mode 100644 index 0000000..aed0f5a --- /dev/null +++ b/compute.py @@ -0,0 +1,89 @@ +import math + +def matmul(mA:list[list[int]], mB:list[list[int]]) -> list[list[int]]: + """ + Matrixmultiplication of matrizes with ints -> returns matrix as result + :param mA: + :param mB: + :return: + :raises ValueError: if Mismatch of Width first matrix and Height of second matrix + """ + + HeightA = len(mA) ## zählt anzahl der listen in der äußeren Liste + WidthA = len(mA[0]) ## zählt anzahl der elemente der nullten Liste + HeightB = len(mB) + WidthB = len(mB[0]) + + if WidthA != HeightB: + raise ValueError('Mismatch of Width of A and Height of B') + + result = [[0 for _ in range(WidthB)] for _ in range(HeightA)] + + + for i in range(HeightA): + for j in range(WidthB): + for k in range(WidthA): + result[i][j] += mA[i][k] * mB[k][j] + + + return result + + +##================================================================================= +def transpose(matrix:list[list[int]]) -> list[list[int]]: + """ + Transposes given matrix + :param matrix: + :return: + :raises: ValueError if Inconsistent number of columns OR matrix is empty + """ + if not matrix: + raise ValueError('matrix is empty') + + height_old = len(matrix) + width_old = len(matrix[0]) + + for i in range(len(matrix) - 1): + if len(matrix[i]) != len(matrix[i + 1]): + raise ValueError('Inconsistent number of columns') + + result = [[0 for _ in range(height_old)] for _ in range(width_old)] + height_new = len(result) + width_new = len(result[0]) + + + for i in range(height_new): + for j in range(width_new): + result[i][j] = matrix[j][i] + + + return result + +##================================================================================= +def rot_2D(bogenmaß: float) -> list[list[float]]: ##auf Bogenmaß + + return [ + [math.cos(bogenmaß), -math.sin(bogenmaß)], + [math.sin(bogenmaß), math.cos(bogenmaß)] + ] + ##rota matrix ist: aus Aufgabe ggben + ## cos -sin + ## sin cos + + + + + + + + + + + + + + + + + +