#NEWLINE# def linearize( self , op_point = None , A_and_B = False , simplify = False ) : #NEWLINE# #INDENT# 'Linearize the system about the operating point. Note that\n        q_op, u_op, qd_op, ud_op must satisfy the equations of motion.\n        These may be either symbolic or numeric.\n\n        Parameters\n        ----------\n        op_point : dict or iterable of dicts, optional\n            Dictionary or iterable of dictionaries containing the operating\n            point conditions. These will be substituted in to the linearized\n            system before the linearization is complete. Leave blank if you\n            want a completely symbolic form. Note that any reduction in\n            symbols (whether substituted for numbers or expressions with a\n            common parameter) will result in faster runtime.\n\n        A_and_B : bool, optional\n            If A_and_B=False (default), (M, A, B) is returned for forming\n            [M]*[q, u]^T = [A]*[q_ind, u_ind]^T + [B]r. If A_and_B=True,\n            (A, B) is returned for forming dx = [A]x + [B]r, where\n            x = [q_ind, u_ind]^T.\n\n        simplify : bool, optional\n            Determines if returned values are simplified before return.\n            For large expressions this may be time consuming. Default is False.\n\n        Potential Issues\n        ----------------\n            Note that the process of solving with A_and_B=True is\n            computationally intensive if there are many symbolic parameters.\n            For this reason, it may be more desirable to use the default\n            A_and_B=False, returning M, A, and B. More values may then be\n            substituted in to these matrices later on. The state space form can\n            then be found as A = P.T*M.LUsolve(A), B = P.T*M.LUsolve(B), where\n            P = Linearizer.perm_mat.\n        ' #NEWLINE# if ( not self . _setup_done ) : #NEWLINE# #INDENT# self . _setup ( ) #NEWLINE# #UNINDENT# if isinstance ( op_point , dict ) : #NEWLINE# #INDENT# op_point_dict = op_point #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( op_point , collections . Iterable ) : #NEWLINE# #INDENT# op_point_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for op in op_point : #NEWLINE# #INDENT# op_point_dict . update ( op ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# op_point_dict = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# #UNINDENT# ( l , m , n , o , s , k ) = self . _dims #NEWLINE# M_qq = self . _M_qq #NEWLINE# M_uqc = self . _M_uqc #NEWLINE# M_uqd = self . _M_uqd #NEWLINE# M_uuc = self . _M_uuc #NEWLINE# M_uud = self . _M_uud #NEWLINE# M_uld = self . _M_uld #NEWLINE# A_qq = self . _A_qq #NEWLINE# A_uqc = self . _A_uqc #NEWLINE# A_uqd = self . _A_uqd #NEWLINE# A_qu = self . _A_qu #NEWLINE# A_uuc = self . _A_uuc #NEWLINE# A_uud = self . _A_uud #NEWLINE# B_u = self . _B_u #NEWLINE# C_0 = self . _C_0 #NEWLINE# C_1 = self . _C_1 #NEWLINE# C_2 = self . _C_2 #NEWLINE# if ( o != 0 ) : #NEWLINE# #INDENT# col2 = Matrix ( [ zeros ( n , o ) , M_uuc , M_uud ] ) #NEWLINE# #UNINDENT# if ( k != 0 ) : #NEWLINE# #INDENT# col3 = Matrix ( [ zeros ( ( n + m ) , k ) , M_uld ] ) #NEWLINE# #UNINDENT# if ( n != 0 ) : #NEWLINE# #INDENT# col1 = Matrix ( [ M_qq , M_uqc , M_uqd ] ) #NEWLINE# if ( ( o != 0 ) and ( k != 0 ) ) : #NEWLINE# #INDENT# M = col1 . row_join ( col2 ) . row_join ( col3 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( o != 0 ) : #NEWLINE# #INDENT# M = col1 . row_join ( col2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# M = col1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( k != 0 ) : #NEWLINE# #INDENT# M = col2 . row_join ( col3 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# M = col2 #NEWLINE# #UNINDENT# #UNINDENT# M_eq = msubs ( M , op_point_dict ) #NEWLINE# if ( n != 0 ) : #NEWLINE# #INDENT# r1c1 = A_qq #NEWLINE# if ( o != 0 ) : #NEWLINE# #INDENT# r1c1 += ( A_qu * C_1 ) #NEWLINE# #UNINDENT# r1c1 = ( r1c1 * C_0 ) #NEWLINE# if ( m != 0 ) : #NEWLINE# #INDENT# r2c1 = Amat #NEWLINE# if ( o != 0 ) : #NEWLINE# #INDENT# r2c1 += ( A_uuc * C_1 ) #NEWLINE# #UNINDENT# r2c1 = ( r2c1 * C_0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r2c1 = Matrix ( ) #NEWLINE# #UNINDENT# if ( ( ( o - m ) + k ) != 0 ) : #NEWLINE# #INDENT# r3c1 = A_uqd #NEWLINE# if ( o != 0 ) : #NEWLINE# #INDENT# r3c1 += ( A_uud * C_1 ) #NEWLINE# #UNINDENT# r3c1 = ( r3c1 * C_0 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r3c1 = Matrix ( ) #NEWLINE# #UNINDENT# col1 = Matrix ( [ r1c1 , r2c1 , r3c1 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# col1 = Matrix ( ) #NEWLINE# #UNINDENT# if ( o != 0 ) : #NEWLINE# #INDENT# if ( n != 0 ) : #NEWLINE# #INDENT# r1c2 = ( A_qu * C_2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r1c2 = Matrix ( ) #NEWLINE# #UNINDENT# if ( m != 0 ) : #NEWLINE# #INDENT# r2c2 = ( A_uuc * C_2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r2c2 = Matrix ( ) #NEWLINE# #UNINDENT# if ( ( ( o - m ) + k ) != 0 ) : #NEWLINE# #INDENT# r3c2 = ( A_uud * C_2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# r3c2 = Matrix ( ) #NEWLINE# #UNINDENT# col2 = Matrix ( [ r1c2 , r2c2 , r3c2 ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# col2 = Matrix ( ) #NEWLINE# #UNINDENT# if col1 : #NEWLINE# #INDENT# if col2 : #NEWLINE# #INDENT# Amat = col1 . row_join ( col2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# Amat = col1 #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# Amat = col2 #NEWLINE# #UNINDENT# Amat_eq = msubs ( Amat , op_point_dict ) #NEWLINE# if ( ( s != 0 ) and ( ( ( o - m ) + k ) != 0 ) ) : #NEWLINE# #INDENT# Bmat = zeros ( ( n + m ) , s ) . col_join ( B_u ) #NEWLINE# Bmat_eq = msubs ( Bmat , op_point_dict ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# Bmat_eq = Matrix ( ) #NEWLINE# #UNINDENT# if A_and_B : #NEWLINE# #INDENT# A_cont = ( self . perm_mat . T * M_eq . LUsolve ( Amat_eq ) ) #NEWLINE# if Bmat_eq : #NEWLINE# #INDENT# B_cont = ( self . perm_mat . T * M_eq . LUsolve ( Bmat_eq ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# B_cont = Bmat_eq #NEWLINE# #UNINDENT# if simplify : #NEWLINE# #INDENT# A_cont . simplify ( ) #NEWLINE# B_cont . simplify ( ) #NEWLINE# #UNINDENT# return ( A_cont , B_cont ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if simplify : #NEWLINE# #INDENT# M_eq . simplify ( ) #NEWLINE# Amat_eq . simplify ( ) #NEWLINE# Bmat_eq . simplify ( ) #NEWLINE# #UNINDENT# return ( M_eq , Amat_eq , Bmat_eq )