@@ -851,7 +851,7 @@ def slycot_laub(self, x):
851851 # transformed state matrices, at, bt, ct.
852852
853853 # Start at the second frequency, already have the first.
854- for kk , x_kk in enumerate (x_arr [1 :len ( x_arr ) ]):
854+ for kk , x_kk in enumerate (x_arr [1 :]):
855855 result = tb05ad (n , m , p , x_kk , at , bt , ct , job = 'NH' )
856856 # When job='NH', result = (g_i, hinvb, info)
857857
@@ -885,15 +885,29 @@ def horner(self, x, warn_infinite=True):
885885 Attempts to use Laub's method from Slycot library, with a
886886 fall-back to python code.
887887 """
888+ # Make sure the argument is a 1D array of complex numbers
889+ x_arr = np .atleast_1d (x ).astype (complex , copy = False )
890+
891+ # return fast on systems with 0 or 1 state
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
904+
888905 try :
889- out = self .slycot_laub (x )
906+ out = self .slycot_laub (x_arr )
890907 except (ImportError , Exception ):
891908 # Fall back because either Slycot unavailable or cannot handle
892909 # certain cases.
893910
894- # Make sure the argument is a 1D array of complex numbers
895- x_arr = np .atleast_1d (x ).astype (complex , copy = False )
896-
897911 # Make sure that we are operating on a simple list
898912 if len (x_arr .shape ) > 1 :
899913 raise ValueError ("input list must be 1D" )
0 commit comments