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

Commit5d680f5

Browse files
authored
Merge pull request#248 from adm78/statesp-performance-improvements
Performance improvements to _remove_useless_states routine in statesp.py
2 parentsb246884 +be53eb7 commit5d680f5

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

‎control/statesp.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,20 +194,15 @@ def _remove_useless_states(self):
194194
195195
"""
196196

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

212207
# Remove the useless states.
213208
self.A=delete(self.A,useless,0)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp