Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit394fa27

Browse files
author
Andrew D. McGuire
committed
Performance improvements to _remove_useless_states routine in statesp.py
1 parent4b0101c commit394fa27

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

‎control/statesp.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -193,20 +193,14 @@ def _remove_useless_states(self):
193193
194194
"""
195195

196-
# Indices of useless states.
197-
useless= []
198-
199196
# Search for useless states.
200-
foriinrange(self.states):
201-
if (all(self.A[i, :]==zeros((1,self.states)))and
202-
all(self.B[i, :]==zeros((1,self.inputs)))):
203-
useless.append(i)
204-
# To avoid duplucate indices in useless, jump to the next
205-
# iteration.
206-
continue
207-
if (all(self.A[:,i]==zeros((self.states,1)))and
208-
all(self.C[:,i]==zeros((self.outputs,1)))):
209-
useless.append(i)
197+
ax1_A=np.where(~self.A.any(axis=1))[0]
198+
ax1_B=np.where(~self.B.any(axis=1))[0]
199+
ax0_A=np.where(~self.A.any(axis=0))[1]
200+
ax0_C=np.where(~self.C.any(axis=0))[1]
201+
useless_1=np.intersect1d(ax1_A,ax1_B,assume_unique=True)
202+
useless_2=np.intersect1d(ax0_A,ax0_C,assume_unique=True)
203+
useless=np.concatenate((useless_1,useless_2))
210204

211205
# Remove the useless states.
212206
self.A=delete(self.A,useless,0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp