Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Check eigenvalues' real part using NumPy
Faster than converting to a pure Python list.
  • Loading branch information
mp4096 committed Nov 20, 2016
commit 71fef4b983d78eb3dc657616b5d51a433f82f396
4 changes: 2 additions & 2 deletions control/modelsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def modred(sys, ELIM, method='matchdc'):


#Check system is stable
if any(e.real >= 0.0 for e in np.linalg.eigvals(sys.A)):
if np.any(np.linalg.eigvals(sys.A).real >= 0.0):
raise ValueError("Oops, the system is unstable!")

ELIM = np.sort(ELIM)
Expand Down Expand Up @@ -251,7 +251,7 @@ def balred(sys, orders, method='truncate'):
dico = 'C'

#Check system is stable
if any(e.real >= 0.0 for e in np.linalg.eigvals(sys.A)):
if np.any(np.linalg.eigvals(sys.A).real >= 0.0):
raise ValueError("Oops, the system is unstable!")

if method=='matchdc':
Expand Down
2 changes: 1 addition & 1 deletion control/statefbk.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def gram(sys,type):

#TODO: Check system is stable, perhaps a utility in ctrlutil.py
# or a method of the StateSpace class?
if any(e.real >= 0.0 for e in np.linalg.eigvals(sys.A)):
if np.any(np.linalg.eigvals(sys.A).real >= 0.0):
raise ValueError("Oops, the system is unstable!")

if type=='c':
Expand Down