zusammenfügen 13.1.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import sympy as sp
|
||||
import numpy as np
|
||||
from typing import Iterable, List, Sequence, Tuple, Optional
|
||||
|
||||
|
||||
@@ -106,50 +107,13 @@ class Datumsfestlegung:
|
||||
sol = K.LUsolve(rhs)
|
||||
return sol[:u, :]
|
||||
|
||||
|
||||
|
||||
@staticmethod
|
||||
def weiches_datum(
|
||||
A: sp.Matrix,
|
||||
dl: sp.Matrix,
|
||||
Q_ll: sp.Matrix,
|
||||
x0: sp.Matrix,
|
||||
anschluss_indices: Sequence[int],
|
||||
anschluss_werte: sp.Matrix,
|
||||
Sigma_AA: Optional[sp.Matrix] = None,
|
||||
) -> Tuple[sp.Matrix, sp.Matrix, sp.Matrix]:
|
||||
if dl.cols != 1 or x0.cols != 1:
|
||||
raise ValueError("dl und x0 müssen Spaltenvektoren sein.")
|
||||
if A.rows != dl.rows:
|
||||
raise ValueError("A.rows muss dl.rows entsprechen.")
|
||||
if A.cols != x0.rows:
|
||||
raise ValueError("A.cols muss x0.rows entsprechen.")
|
||||
if Q_ll.rows != Q_ll.cols or Q_ll.rows != A.rows:
|
||||
raise ValueError("Q_ll muss (n×n) sein und zu A.rows passen.")
|
||||
|
||||
u = A.cols
|
||||
idx = [int(i) for i in anschluss_indices]
|
||||
m = len(idx)
|
||||
|
||||
if anschluss_werte.cols != 1 or anschluss_werte.rows != m:
|
||||
raise ValueError("anschluss_werte muss (m×1) sein.")
|
||||
if Sigma_AA is None:
|
||||
Sigma_AA = sp.eye(m)
|
||||
if Sigma_AA.rows != m or Sigma_AA.cols != m:
|
||||
raise ValueError("Sigma_AA muss (m×m) sein.")
|
||||
|
||||
A_A = sp.zeros(m, u)
|
||||
for r, j in enumerate(idx):
|
||||
if not (0 <= j < u):
|
||||
raise IndexError(f"Anschluss-Index {j} außerhalb [0,{u-1}]")
|
||||
A_A[r, j] = 1
|
||||
|
||||
x0_A = sp.Matrix([[x0[j, 0]] for j in idx])
|
||||
dl_A = anschluss_werte - x0_A
|
||||
|
||||
A_ext = A.col_join(A_A)
|
||||
dl_ext = dl.col_join(dl_A)
|
||||
|
||||
Q_ext = sp.zeros(Q_ll.rows + m, Q_ll.cols + m)
|
||||
Q_ext[:Q_ll.rows, :Q_ll.cols] = Q_ll
|
||||
Q_ext[Q_ll.rows:, Q_ll.cols:] = Sigma_AA
|
||||
|
||||
return A_ext, dl_ext, Q_ext
|
||||
def weiches_datum(Q_ll: np.ndarray, Q_AA: np.ndarray) -> np.ndarray:
|
||||
if Q_ll.ndim != 2 or Q_ll.shape[0] != Q_ll.shape[1]:
|
||||
raise ValueError("Q_ll muss quadratisch sein.")
|
||||
if Q_AA.ndim != 2 or Q_AA.shape[0] != Q_AA.shape[1]:
|
||||
raise ValueError("Q_AA muss quadratisch sein.")
|
||||
Q_ext = np.block([[Q_ll, np.zeros((Q_ll.shape[0], Q_AA.shape[0]))],[np.zeros((Q_AA.shape[0], Q_ll.shape[0])), Q_AA]])
|
||||
return Q_ext
|
||||
Reference in New Issue
Block a user