parameters: (self, other)
return_statement: return StateSpace(np.asarray(a, dtype=common_dtype),
                            np.asarray(b, dtype=common_dtype),
                            np.asarray(c, dtype=common_dtype),
                            np.asarray(d, dtype=common_dtype))
docstring: Adds two systems in the sense of frequency domain addition.
docstring_summary: Adds two systems in the sense of frequency domain addition.
docstring_tokens: Adds two systems in the sense of frequency domain addition .
function: def __add__(self, other):
          """
          Adds two systems in the sense of frequency domain addition.
          """
          if not self._check_binop_other(other):
              return NotImplemented
  
          if isinstance(other, StateSpace):
              # Disallow mix of discrete and continuous systems.
              if type(other) is not type(self):
                  raise TypeError('Cannot add {} and {}'.format(type(self),
                                                                type(other)))
  
              if self.dt != other.dt:
                  raise TypeError('Cannot add systems with different `dt`.')
              # Interconnection of systems
              # x1' = A1 x1 + B1 u
              # y1  = C1 x1 + D1 u
              # x2' = A2 x2 + B2 u
              # y2  = C2 x2 + D2 u
              # y   = y1 + y2
              #
              # Plugging in yields
              # [x1']   [A1 0 ] [x1]   [B1]
              # [x2'] = [0  A2] [x2] + [B2] u
              #                 [x1]
              #  y    = [C1 C2] [x2] + [D1 + D2] u
              a = linalg.block_diag(self.A, other.A)
              b = np.vstack((self.B, other.B))
              c = np.hstack((self.C, other.C))
              d = self.D + other.D
          else:
              other = np.atleast_2d(other)
              if self.D.shape == other.shape:
                  # A scalar/matrix is really just a static system (A=0, B=0, C=0)
                  a = self.A
                  b = self.B
                  c = self.C
                  d = self.D + other
              else:
                  raise ValueError("Cannot add systems with incompatible dimensions")
  
          common_dtype = np.find_common_type((a.dtype, b.dtype, c.dtype, d.dtype), ())
          return StateSpace(np.asarray(a, dtype=common_dtype),
                            np.asarray(b, dtype=common_dtype),
                            np.asarray(c, dtype=common_dtype),
                            np.asarray(d, dtype=common_dtype))
function_tokens: def __add__ ( self , other ) : if not self . _check_binop_other ( other ) : return NotImplemented if isinstance ( other , StateSpace ) : # Disallow mix of discrete and continuous systems. if type ( other ) is not type ( self ) : raise TypeError ( 'Cannot add {} and {}' . format ( type ( self ) , type ( other ) ) ) if self . dt != other . dt : raise TypeError ( 'Cannot add systems with different `dt`.' ) # Interconnection of systems # x1' = A1 x1 + B1 u # y1  = C1 x1 + D1 u # x2' = A2 x2 + B2 u # y2  = C2 x2 + D2 u # y   = y1 + y2 # # Plugging in yields # [x1']   [A1 0 ] [x1]   [B1] # [x2'] = [0  A2] [x2] + [B2] u #                 [x1] #  y    = [C1 C2] [x2] + [D1 + D2] u a = linalg . block_diag ( self . A , other . A ) b = np . vstack ( ( self . B , other . B ) ) c = np . hstack ( ( self . C , other . C ) ) d = self . D + other . D else : other = np . atleast_2d ( other ) if self . D . shape == other . shape : # A scalar/matrix is really just a static system (A=0, B=0, C=0) a = self . A b = self . B c = self . C d = self . D + other else : raise ValueError ( "Cannot add systems with incompatible dimensions" ) common_dtype = np . find_common_type ( ( a . dtype , b . dtype , c . dtype , d . dtype ) , ( ) ) return StateSpace ( np . asarray ( a , dtype = common_dtype ) , np . asarray ( b , dtype = common_dtype ) , np . asarray ( c , dtype = common_dtype ) , np . asarray ( d , dtype = common_dtype ) )