@@ -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,27 @@ 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 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
902
+
888
903
try :
889
- out = self .slycot_laub (x )
904
+ out = self .slycot_laub (x_arr )
890
905
except (ImportError , Exception ):
891
906
# Fall back because either Slycot unavailable or cannot handle
892
907
# certain cases.
893
908
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
909
# Make sure that we are operating on a simple list
898
910
if len (x_arr .shape ) > 1 :
899
911
raise ValueError ("input list must be 1D" )
0 commit comments