Skip to content

Commit

Permalink
try, except to catch errors in pinv
Browse files Browse the repository at this point in the history
  • Loading branch information
Abdu-Hekal authored and EthanJamesLew committed Apr 16, 2024
1 parent 4bec0ad commit d04d862
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions autokoopman/estimator/koopman.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ def dmdc(X, Xp, U, r):
U, Sigma, V = U[:, :r], np.diag(Sigma)[:r, :r], V.conj().T[:, :r]

# get the transformation
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
try:
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
except:
Atilde = Yp @ V @ np.linalg.pinv(Sigma) @ U.conj().T

return Atilde[:, :state_size], Atilde[:, state_size:]


Expand All @@ -48,7 +52,10 @@ def wdmdc(X, Xp, U, r, W):
U, Sigma, V = U[:, :r], np.diag(Sigma)[:r, :r], V.conj().T[:, :r]

# get the transformation
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
try:
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
except:
Atilde = Yp @ V @ np.linalg.pinv(Sigma) @ U.conj().T
return Atilde[:, :state_size], Atilde[:, state_size:]


Expand Down

0 comments on commit d04d862

Please sign in to comment.