Skip to content

Commit acfc535

Browse files
committed
try, except to catch errors in pinv
1 parent 2eefa6a commit acfc535

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

autokoopman/estimator/koopman.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ def dmdc(X, Xp, U, r):
2626
U, Sigma, V = U[:, :r], np.diag(Sigma)[:r, :r], V.conj().T[:, :r]
2727

2828
# get the transformation
29-
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
29+
try:
30+
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
31+
except:
32+
Atilde = Yp @ V @ np.linalg.pinv(Sigma) @ U.conj().T
33+
3034
return Atilde[:, :state_size], Atilde[:, state_size:]
3135

3236

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

5054
# get the transformation
51-
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
55+
try:
56+
Atilde = Yp @ V @ np.linalg.inv(Sigma) @ U.conj().T
57+
except:
58+
Atilde = Yp @ V @ np.linalg.pinv(Sigma) @ U.conj().T
5259
return Atilde[:, :state_size], Atilde[:, state_size:]
5360

5461

0 commit comments

Comments
 (0)