compute.py hinzugefügt
This commit is contained in:
commit
a93f84c60e
31
compute.py
Normal file
31
compute.py
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# compute.py (relevante Funktionen)
|
||||||
|
from tabulate import tabulate
|
||||||
|
|
||||||
|
import math
|
||||||
|
from typing import List
|
||||||
|
|
||||||
|
Matrix = List[List[float]]
|
||||||
|
|
||||||
|
def rot_2D(theta: float) -> Matrix:
|
||||||
|
cos_theta = math.cos(theta)
|
||||||
|
sin_theta = math.sin(theta)
|
||||||
|
return [
|
||||||
|
[cos_theta, -sin_theta],
|
||||||
|
[sin_theta, cos_theta]
|
||||||
|
]
|
||||||
|
|
||||||
|
def matmul(a: Matrix, b: Matrix) -> Matrix:
|
||||||
|
if len(a[0]) != len(b):
|
||||||
|
raise ValueError("Spalten von A müssen gleich Zeilen von B sein.")
|
||||||
|
result = [[0]*len(b[0]) for _ in range(len(a))]
|
||||||
|
for i in range(len(a)):
|
||||||
|
for j in range(len(b[0])):
|
||||||
|
for k in range(len(b)):
|
||||||
|
result[i][j] += a[i][k] * b[k][j]
|
||||||
|
return result
|
||||||
|
|
||||||
|
if _name_ == "_main_":
|
||||||
|
# habe ich alles selbst programmiert
|
||||||
|
matrix_a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
|
||||||
|
print("Test Matrix A:")
|
||||||
|
print(tabulate(matrix_a)) ##
|
||||||
Loading…
x
Reference in New Issue
Block a user