commit c20f8a484ef1fd2853ed2580bd545611fac40dbb Author: Phexi Date: Thu Oct 22 00:21:46 2026 +0200 erster stand :) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d1eb6e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +.venv/ +__pycache__/ +.env \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ 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/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..67e3e60 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,12 @@ + + + + \ 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/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b79339d --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ 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/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..c47fb62 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,2 @@ +# Regeln für dieses Projekt +- I don't like you please dni \ No newline at end of file diff --git a/compute.py b/compute.py new file mode 100644 index 0000000..c358459 --- /dev/null +++ b/compute.py @@ -0,0 +1,134 @@ +"""Compute module providing matrix multiplication functionality. + +This module defines a single public function :func:`matmul`, which performs +standard matrix multiplication for two 2‑D lists. + +The function explicitly checks that the number of columns of the first matrix +matches the number of rows of the second matrix. If they are mismatched the +function prints ``"Matrices not compatible :("`` and returns an empty list. + +All variables are named distinctly to aid readability and to avoid +conflicts. +""" + + + +__all__: list[str] = ["matmul", "transpose"] + +import math + + +def matmul( + matrix_a: list[list[float]], + matrix_b: list[list[float]], +) -> list[list[float]]: + """Return the product of two matrices. + + Parameters + ---------- + matrix_a: list[list[float]] + The left‑hand operand, a 2‑D list where each inner list represents a row. + matrix_b: list[list[float]] + The right‑hand operand, also a 2‑D list. + + Returns + ------- + list[list[float]] + The resulting matrix as a 2‑D list. If the matrices cannot be + multiplied due to incompatible dimensions, an empty list is returned. + + Examples + -------- + # >>> matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]]) + [[19.0, 22.0], [43.0, 50.0]] + """ + + if not matrix_a or not matrix_b: + print("Matrices not compatible :(") + return [] + + rows_a: int = len(matrix_a) + cols_a: int = len(matrix_a[0]) + rows_b: int = len(matrix_b) + cols_b: int = len(matrix_b[0]) + + if cols_a != rows_b: + print("Matrices not compatible :(") + return [] + + # Initialise result matrix with zeros + result: list[list[float]] = [[0.0 for _ in range(cols_b)] for _ in range(rows_a)] + + for i in range(rows_a): + for j in range(cols_b): + sum_val: float = 0.0 + for k in range(cols_a): + sum_val += matrix_a[i][k] * matrix_b[k][j] + result[i][j] = sum_val + + return result + + + + + + + +def get_rotate(matrix: list[list[float]], angle:int) -> list[list[float]]: + """Apply a rotation matrix to a base matrix. + + Parameters + ---------- + matrix: list[list[float]] + The matrix to be rotated. + angle: int + The angle to be rotated. + + Returns + ------- + list[list[float]] + Result of *matrix* rotated by *angle*. + """ + + rows: int = len(matrix) + cols: int = len(matrix[0]) + if cols != 1: + print("Can't rotate this matrix! Wrong amount of columns!") + return [[0, 0],[0, 0]] + if rows == 2: + return [[math.cos(angle), -math.sin(angle)], [math.sin(angle), math.cos(angle)]] + else: + print("Can't rotate this matrix! Wrong amount of rows!") + return [[0, 0],[0, 0]] + return matmul(rotate_matrix, matrix) + + +def transpose(matrix: list[list[float]]) -> list[list[float]]: + """Return the transpose of a 2‑D list. + + Parameters + ---------- + matrix: list[list[float]] + The matrix to transpose. + + Returns + ------- + list[list[float]] + Transposed matrix. + """ + if not matrix: + return [] + rows = len(matrix) + cols = len(matrix[0]) + result: list[list[float]] = [[None for _ in range(rows)] for _ in range(cols)] + for i in range(rows): + for j in range(cols): + result[j][i] = matrix[i][j] + return result + + + +if __name__ == "__main__": + print(matmul([[1, 2], [3, 4]], [[5, 6], [7, 8]])) + print(transpose([[1, 2], [3, 4]])) + print(len([[1],[0]])) \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..46e3b47 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[project] +name = "matrixmania" +version = "0.1.0" \ No newline at end of file