Singulärwertzerlegung

This commit is contained in:
Sandro Zimmermann 2026-06-02 22:04:57 +02:00
parent bc4602eb7d
commit 827588a435

View File

@ -0,0 +1,42 @@
"""
Singulärwertzerlegung SVD
A Matrix:
[4 6]
[3 -8]
"""
import numpy as np
import scipy as sc
# Parameter
A = np.array([[4.0, 6.0], [3.0, -8.0]])
pr = 3
# Berechnung
[U, S, Vt] = sc.linalg.svd(A)
# Ausgabe
with np.printoptions(precision=pr):
print(f"U = \n{U}\n\nS = \n{S}\n\nV = \n{Vt.T}")
"""
Ausgabe:
U =
[[-0.6 -0.8]
[ 0.8 -0.6]]
S =
[10. 5.]
V =
[[-0. -1.]
[-1. -0.]]
"""
# S = Vektor mit den Singulärwerten (o1, o2)
# Nicht die ganze Matrix:
# [10 0]
# [0 5]