Skip to content

Commit 5355b02

Browse files
committed
only return fast in array, not matrix
1 parent 433c136 commit 5355b02

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

control/statesp.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -889,16 +889,18 @@ def horner(self, x, warn_infinite=True):
889889
x_arr = np.atleast_1d(x).astype(complex, copy=False)
890890

891891
# return fast on systems with 0 or 1 state
892-
if self.nstates == 0:
893-
return self.D[:, :, np.newaxis] \
894-
* np.ones_like(x_arr, dtype=complex)
895-
if self.nstates == 1:
896-
with np.errstate(divide='ignore', invalid='ignore'):
897-
out = (self.C[:, :, np.newaxis]
898-
* (self.B[:, :, np.newaxis] / (x_arr - self.A[0, 0]))
899-
+ self.D[:, :, np.newaxis])
900-
out[np.isnan(out)] = complex(np.inf, np.nan)
901-
return out
892+
if not config.defaults['statesp.use_numpy_matrix']:
893+
if self.nstates == 0:
894+
return self.D[:, :, np.newaxis] \
895+
* np.ones_like(x_arr, dtype=complex)
896+
if self.nstates == 1:
897+
with np.errstate(divide='ignore', invalid='ignore'):
898+
out = self.C[:, :, np.newaxis] \
899+
/ (x_arr - self.A[0, 0]) \
900+
* self.B[:, :, np.newaxis] \
901+
+ self.D[:, :, np.newaxis]
902+
out[np.isnan(out)] = complex(np.inf, np.nan)
903+
return out
902904

903905
try:
904906
out = self.slycot_laub(x_arr)

0 commit comments

Comments
 (0)