compute added
This commit is contained in:
parent
300706bc9d
commit
39ec6e2061
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal 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
10
.idea/MatrixMania.iml
generated
Normal 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>
|
||||||
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
6
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<profile version="1.0">
|
||||||
|
<option name="myName" value="Project Default" />
|
||||||
|
<inspection_tool class="LanguageDetectionInspection" enabled="false" level="WARNING" enabled_by_default="false" />
|
||||||
|
</profile>
|
||||||
|
</component>
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.12 (MatrixMania)" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal 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>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
80
compute..py
Normal file
80
compute..py
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
from typing import List
|
||||||
|
import math
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
def matmul(matrix_a: List[List[int]], matrix_b: List[List[int]]) -> List[List[int]]:
|
||||||
|
"""
|
||||||
|
Matrix multiplication
|
||||||
|
:param matrix_a: Matrix A
|
||||||
|
:param matrix_b: Matrix B
|
||||||
|
:return: product of matrix_a and matrix_b
|
||||||
|
:raises: ValueError: wenn Matrix A and Matrix B nicht multipliezierbar sind
|
||||||
|
"""
|
||||||
|
|
||||||
|
if len(matrix_a[0]) != len(matrix_b):
|
||||||
|
print(len(matrix_a[0]))
|
||||||
|
print(len(matrix_b))
|
||||||
|
raise ValueError("Matrix kann nicht multipliziert werden")
|
||||||
|
|
||||||
|
ergebnis1 = []
|
||||||
|
ergebnis2 = []
|
||||||
|
result = 0
|
||||||
|
spalte_max = len(matrix_b[0])
|
||||||
|
zeile = 0
|
||||||
|
|
||||||
|
for spalte in range(len(matrix_a)):
|
||||||
|
for zeile in range(spalte_max):
|
||||||
|
for z in range(len(matrix_a[0])):
|
||||||
|
zahl = matrix_a[spalte][z] * matrix_b[z][zeile]
|
||||||
|
result = result + zahl
|
||||||
|
ergebnis1.append(result)
|
||||||
|
result = 0
|
||||||
|
ergebnis2.append(ergebnis1)
|
||||||
|
ergebnis1 = []
|
||||||
|
|
||||||
|
return ergebnis2
|
||||||
|
|
||||||
|
def transpose(matrix: list[list[int]]) -> list[list[int]]:
|
||||||
|
"""
|
||||||
|
Transpose a matrix
|
||||||
|
:param matrix: valid matrix
|
||||||
|
:return: transpose of matrix
|
||||||
|
"""
|
||||||
|
if len(matrix) == 0:
|
||||||
|
raise ValueError("Matrix leer")
|
||||||
|
mindest_länge = len(matrix[0])
|
||||||
|
for zeile in range(len(matrix)):
|
||||||
|
if len(matrix[zeile]) != mindest_länge :
|
||||||
|
raise ValueError("Matrix falsch")
|
||||||
|
|
||||||
|
anzahl_spalten= len(matrix)
|
||||||
|
anzahl_zeilen= len(matrix[0])
|
||||||
|
ergebnis1 = []
|
||||||
|
ergebnis2 = []
|
||||||
|
for z in range(anzahl_zeilen):
|
||||||
|
for s in range(anzahl_spalten):
|
||||||
|
ergebnis1.append(matrix[s][z])
|
||||||
|
|
||||||
|
ergebnis2.append(ergebnis1)
|
||||||
|
ergebnis1 = []
|
||||||
|
|
||||||
|
return ergebnis2
|
||||||
|
|
||||||
|
|
||||||
|
def rot_2D(angle: int) -> List[List[int]]:
|
||||||
|
"""
|
||||||
|
Rotation matrix
|
||||||
|
:param angle: any angle
|
||||||
|
:return: rotation matrix
|
||||||
|
"""
|
||||||
|
zahl1 = math.cos(math.radians(angle))
|
||||||
|
zahl2 = -math.sin(math.radians(angle))
|
||||||
|
zahl3 = math.sin(math.radians(angle))
|
||||||
|
zahl4 = math.cos(math.radians(angle))
|
||||||
|
|
||||||
|
return [[zahl1, zahl2], [zahl3, zahl4]]
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
|
||||||
|
print(rot_2D())
|
||||||
Loading…
x
Reference in New Issue
Block a user