@@ -220,7 +220,8 @@ def __mul__(self, other):
220220
221221 # Convert the second argument to a transfer function.
222222 if isinstance (other , (int , float , complex )):
223- return FRD (self .fresp * other , self .omega )
223+ return FRD (self .fresp * other , self .omega ,
224+ smooth = (self .ifunc is not None ))
224225 else :
225226 other = _convertToFRD (other , omega = self .omega )
226227
@@ -236,14 +237,17 @@ def __mul__(self, other):
236237 dtype = self .fresp .dtype )
237238 for i in range (len (self .omega )):
238239 fresp [:,:,i ] = dot (self .fresp [:,:,i ], other .fresp [:,:,i ])
239- return FRD (fresp , self .omega )
240+ return FRD (fresp , self .omega ,
241+ smooth = (self .ifunc is not None ) and
242+ (other .ifunc is not None ))
240243
241244 def __rmul__ (self , other ):
242245 """Right Multiply two LTI objects (serial connection)."""
243246
244247 # Convert the second argument to an frd function.
245248 if isinstance (other , (int , float , complex )):
246- return FRD (self .fresp * other , self .omega )
249+ return FRD (self .fresp * other , self .omega ,
250+ smooth = (self .ifunc is not None ))
247251 else :
248252 other = _convertToFRD (other , omega = self .omega )
249253
@@ -260,14 +264,17 @@ def __rmul__(self, other):
260264 dtype = self .fresp .dtype )
261265 for i in range (len (self .omega )):
262266 fresp [:,:,i ] = dot (other .fresp [:,:,i ], self .fresp [:,:,i ])
263- return FRD (fresp , self .omega )
267+ return FRD (fresp , self .omega ,
268+ smooth = (self .ifunc is not None ) and
269+ (other .ifunc is not None ))
264270
265271 # TODO: Division of MIMO transfer function objects is not written yet.
266272 def __truediv__ (self , other ):
267273 """Divide two LTI objects."""
268274
269275 if isinstance (other , (int , float , complex )):
270- return FRD (self .fresp * (1 / other ), self .omega )
276+ return FRD (self .fresp * (1 / other ), self .omega ,
277+ smooth = (self .ifunc is not None ))
271278 else :
272279 other = _convertToFRD (other , omega = self .omega )
273280
@@ -277,7 +284,9 @@ def __truediv__(self, other):
277284 raise NotImplementedError (
278285 "FRD.__truediv__ is currently implemented only for SISO systems." )
279286
280- return FRD (self .fresp / other .fresp , self .omega )
287+ return FRD (self .fresp / other .fresp , self .omega ,
288+ smooth = (self .ifunc is not None ) and
289+ (other .ifunc is not None ))
281290
282291 # TODO: Remove when transition to python3 complete
283292 def __div__ (self , other ):
@@ -287,7 +296,8 @@ def __div__(self, other):
287296 def __rtruediv__ (self , other ):
288297 """Right divide two LTI objects."""
289298 if isinstance (other , (int , float , complex )):
290- return FRD (other / self .fresp , self .omega )
299+ return FRD (other / self .fresp , self .omega ,
300+ smooth = (self .ifunc is not None ))
291301 else :
292302 other = _convertToFRD (other , omega = self .omega )
293303
@@ -306,7 +316,8 @@ def __pow__(self,other):
306316 if not type (other ) == int :
307317 raise ValueError ("Exponent must be an integer" )
308318 if other == 0 :
309- return FRD (ones (self .fresp .shape ),self .omega ) #unity
319+ return FRD (ones (self .fresp .shape ),self .omega ,
320+ smooth = (self .ifunc is not None )) #unity
310321 if other > 0 :
311322 return self * (self ** (other - 1 ))
312323 if other < 0 :
@@ -338,7 +349,7 @@ def evalfr(self, omega):
338349 except :
339350 raise ValueError (
340351 "Frequency %f not in frequency list, try an interpolating"
341- " FRD if you want additional points" )
352+ " FRD if you want additional points" % omega )
342353 else :
343354 if getattr (omega , '__iter__' , False ):
344355 for i in range (self .outputs ):
@@ -401,7 +412,7 @@ def feedback(self, other=1, sign=-1):
401412 self .fresp [:, :, k ].view (type = matrix ),
402413 eye (self .inputs ))
403414
404- return FRD (fresp , other .omega )
415+ return FRD (fresp , other .omega , smooth = ( self . ifunc is not None ) )
405416
406417def _convertToFRD (sys , omega , inputs = 1 , outputs = 1 ):
407418 """Convert a system to frequency response data form (if needed).
@@ -436,11 +447,11 @@ def _convertToFRD(sys, omega, inputs=1, outputs=1):
436447 for k , w in enumerate (omega ):
437448 fresp [:, :, k ] = sys .evalfr (w )
438449
439- return FRD (fresp , omega )
450+ return FRD (fresp , omega , smooth = True )
440451
441452 elif isinstance (sys , (int , float , complex )):
442453 fresp = ones ((outputs , inputs , len (omega )), dtype = float )* sys
443- return FRD (fresp , omega )
454+ return FRD (fresp , omega , smooth = True )
444455
445456 # try converting constant matrices
446457 try :
@@ -450,7 +461,7 @@ def _convertToFRD(sys, omega, inputs=1, outputs=1):
450461 for i in range (outputs ):
451462 for j in range (inputs ):
452463 fresp [i ,j ,:] = sys [i ,j ]
453- return FRD (fresp , omega )
464+ return FRD (fresp , omega , smooth = True )
454465 except :
455466 pass
456467
0 commit comments