Skip to content

Commit bf6c446

Browse files
committed
Added singularity check to the residualization method
* Changed the unit test in matlab_test.py so that no error is thrown
1 parent 1fe639c commit bf6c446

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

control/modelsimp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ def modred(sys, ELIM, method='matchdc'):
181181
# if matchdc, residualize
182182

183183
# Check if the matrix A22 is invertible
184-
# if np.linalg.matrix_rank(A22) != len(ELIM):
185-
# raise ValueError("Matrix A22 is singular to working precision.")
184+
if np.linalg.matrix_rank(A22) != len(ELIM):
185+
raise ValueError("Matrix A22 is singular to working precision.")
186186

187187
# Now precompute A22\A21 and A22\B2 (A22I = inv(A22))
188188
# We can solve two linear systems in one pass, since the

control/tests/matlab_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def testBalred(self):
363363

364364
def testModred(self):
365365
modred(self.siso_ss1, [1])
366-
modred(self.siso_ss2 * self.siso_ss3, [1, 2])
366+
modred(self.siso_ss2 * self.siso_ss3, [0, 1])
367367
modred(self.siso_ss3, [1], 'matchdc')
368368
modred(self.siso_ss3, [1], 'truncate')
369369

0 commit comments

Comments
 (0)