LR-Zerlegung
This commit is contained in:
parent
fbd6476bad
commit
92e2f991e3
37
src/klausurvorbereitung/lr_zerlegung.py
Normal file
37
src/klausurvorbereitung/lr_zerlegung.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"""
|
||||||
|
LR-Zerlegung
|
||||||
|
|
||||||
|
Matrix A:
|
||||||
|
|
||||||
|
[3, 2]
|
||||||
|
[1, 4]
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import scipy as sc
|
||||||
|
|
||||||
|
# Parameter
|
||||||
|
A = np.array([[3, 2], [1, 4]])
|
||||||
|
pr = 3
|
||||||
|
|
||||||
|
[P, L, R] = sc.linalg.lu(A)
|
||||||
|
|
||||||
|
with np.printoptions(precision=pr):
|
||||||
|
print(f"P = \n{P}\n\nL = \n{L}\n\nR = \n{R}")
|
||||||
|
|
||||||
|
"""
|
||||||
|
Ausgabe:
|
||||||
|
|
||||||
|
P =
|
||||||
|
[[1. 0.]
|
||||||
|
[0. 1.]]
|
||||||
|
|
||||||
|
L =
|
||||||
|
[[1. 0. ]
|
||||||
|
[0.333 1. ]]
|
||||||
|
|
||||||
|
R =
|
||||||
|
[[3. 2. ]
|
||||||
|
[0. 3.333]]
|
||||||
|
"""
|
||||||
Loading…
x
Reference in New Issue
Block a user