@@ -851,7 +851,7 @@ def slycot_laub(self, x):
851
851
# transformed state matrices, at, bt, ct.
852
852
853
853
# 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 :]):
855
855
result = tb05ad (n , m , p , x_kk , at , bt , ct , job = 'NH' )
856
856
# When job='NH', result = (g_i, hinvb, info)
857
857
@@ -885,15 +885,29 @@ def horner(self, x, warn_infinite=True):
885
885
Attempts to use Laub's method from Slycot library, with a
886
886
fall-back to python code.
887
887
"""
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
+
888
905
try :
889
- out = self .slycot_laub (x )
906
+ out = self .slycot_laub (x_arr )
890
907
except (ImportError , Exception ):
891
908
# Fall back because either Slycot unavailable or cannot handle
892
909
# certain cases.
893
910
894
- # Make sure the argument is a 1D array of complex numbers
895
- x_arr = np .atleast_1d (x ).astype (complex , copy = False )
896
-
897
911
# Make sure that we are operating on a simple list
898
912
if len (x_arr .shape ) > 1 :
899
913
raise ValueError ("input list must be 1D" )
0 commit comments