Skip to content
Merged
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
only return fast in array, not matrix
  • Loading branch information
bnavigator committed Nov 2, 2021
commit 5355b025f90ed0838f3e540f8983aa37ce504a43
22 changes: 12 additions & 10 deletions control/statesp.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,16 +889,18 @@ def horner(self, x, warn_infinite=True):
x_arr = np.atleast_1d(x).astype(complex, copy=False)

# return fast on systems with 0 or 1 state
if self.nstates == 0:
return self.D[:, :, np.newaxis] \
* np.ones_like(x_arr, dtype=complex)
if self.nstates == 1:
with np.errstate(divide='ignore', invalid='ignore'):
out = (self.C[:, :, np.newaxis]
* (self.B[:, :, np.newaxis] / (x_arr - self.A[0, 0]))
+ self.D[:, :, np.newaxis])
out[np.isnan(out)] = complex(np.inf, np.nan)
return out
if not config.defaults['statesp.use_numpy_matrix']:
if self.nstates == 0:
return self.D[:, :, np.newaxis] \
* np.ones_like(x_arr, dtype=complex)
if self.nstates == 1:
with np.errstate(divide='ignore', invalid='ignore'):
out = self.C[:, :, np.newaxis] \
/ (x_arr - self.A[0, 0]) \
* self.B[:, :, np.newaxis] \
+ self.D[:, :, np.newaxis]
out[np.isnan(out)] = complex(np.inf, np.nan)
return out

try:
out = self.slycot_laub(x_arr)
Expand Down