@@ -554,7 +554,9 @@ def __neg__(self):
554554 for i in range (self .noutputs ):
555555 for j in range (self .ninputs ):
556556 num [i , j ] *= - 1
557- return TransferFunction (num , self .den , self .dt )
557+ return TransferFunction (
558+ num , self .den , self .dt ,
559+ inputs = self .input_labels , outputs = self .output_labels )
558560
559561 def __add__ (self , other ):
560562 """Add two LTI objects (parallel connection)."""
@@ -620,8 +622,13 @@ def __mul__(self, other):
620622 if isinstance (other , (StateSpace , np .ndarray )):
621623 other = _convert_to_transfer_function (other )
622624 elif isinstance (other , (int , float , complex , np .number )):
623- # Multiply by a scaled identity matrix (transfer function)
624- other = _convert_to_transfer_function (np .eye (self .ninputs ) * other )
625+ num = deepcopy (self .num_array )
626+ for i in range (self .noutputs ):
627+ for j in range (self .ninputs ):
628+ num [i , j ] *= other
629+ return TransferFunction (
630+ num , self .den , self .dt ,
631+ inputs = self .input_labels , outputs = self .output_labels )
625632 if not isinstance (other , TransferFunction ):
626633 return NotImplemented
627634
@@ -669,8 +676,13 @@ def __rmul__(self, other):
669676
670677 # Convert the second argument to a transfer function.
671678 if isinstance (other , (int , float , complex , np .number )):
672- # Multiply by a scaled identity matrix (transfer function)
673- other = _convert_to_transfer_function (np .eye (self .noutputs ) * other )
679+ num = deepcopy (self .num_array )
680+ for i in range (self .noutputs ):
681+ for j in range (self .ninputs ):
682+ num [i , j ] *= other
683+ return TransferFunction (
684+ num , self .den , self .dt ,
685+ inputs = self .input_labels , outputs = self .output_labels )
674686 else :
675687 other = _convert_to_transfer_function (other )
676688
0 commit comments