This commit is contained in:
Marco Di Martino 2025-11-06 15:15:07 +01:00
commit 4ade79c4fc
5 changed files with 75 additions and 0 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -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

10
.idea/MatrixMania.iml generated Normal file
View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.12 (MatrixMania)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/MatrixMania.iml" filepath="$PROJECT_DIR$/.idea/MatrixMania.iml" />
</modules>
</component>
</project>

43
compute.py Normal file
View File

@ -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