2022-09-28 10:31:16 +02:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
A = np.array([[1, 2, 3, 4],
|
|
|
|
[2, 3, 4, 1],
|
|
|
|
[3, 4, 1, 2],
|
|
|
|
[4, 1, 2, 3]])
|
|
|
|
|
|
|
|
B = np.array([[5, 4, 3, 2],
|
|
|
|
[4, 3, 2, 5],
|
|
|
|
[3, 2, 5, 4],
|
|
|
|
[2, 5, 4, 3]])
|
|
|
|
|
|
|
|
b = np.array([[1],
|
|
|
|
[2],
|
|
|
|
[3],
|
|
|
|
[4]])
|
|
|
|
|
|
|
|
#Task A:
|
|
|
|
print("Ab:\n", A @ b)
|
|
|
|
print("Bb:\n", B @ b)
|
|
|
|
print("A^T:\n", A.T)
|
|
|
|
print("B^T:\n", B.T)
|
|
|
|
print("A^TA:\n", A.T @ A)
|
2022-09-28 10:34:35 +02:00
|
|
|
print("B^TB:\n", B.T @ B)
|
|
|
|
|
|
|
|
#Task B:
|
|
|
|
print("4. Zeile von A x 2. Spalte von B:\n", A[3, :] @ B[:, 1])
|
|
|
|
|
2022-09-28 10:42:36 +02:00
|
|
|
#Task C:
|
|
|
|
print("Spaltensumme A:\n", A.sum(0))
|
|
|
|
print("Zeilensumme B:\n", B.sum(1))
|