Beispiel #1
0
def row_proper(A):
    """
    Reduction of a polynomial matrix to row proper polynomial matrix

    Implementation of the algorithm as shown in page 7 of 
    Vardulakis, A.I.G. (Antonis I.G). Linear Multivariable Control: Algebraic Analysis and Synthesis Methods. 
    Chichester,New York,Brisbane,Toronto,Singapore: John Wiley & Sons, 1991.

    INPUT:
        Polynomial Matrix A
    OUTPUT:
        T:An equivalent matrix in row proper form
        TL the unimodular transformation matrix
    Christos Tsolakis
    
    Example:  TODO
    T=Matrix([[1, s**2, 0], [0, s, 1]])
    is_row_proper(T)
    
    see also Wolovich Linear Multivariable Systems Springer
    """
    T=A.copy()
    Transfomation_Matrix=eye(T.rows)     #initialize transformation matrix
    while  not is_row_proper(T):
        #for i in range(3):
        Thr=mc.highest_row_degree_matrix(T,s)
        #pprint(Thr)
        x=symbols('x0:%d'%(Thr.rows+1))
        Thr=Thr.transpose()
        Thr0=Thr.col_insert(Thr.cols,zeros(Thr.rows,1))
        SOL=solve_linear_system(Thr0,*x)      # solve the system 
        a=Matrix(x)
        D={var:1 for var in x if var not in SOL.keys()}   # put free variables equal to 1
        D.update({var:SOL[var].subs(D) for var in x if var in SOL.keys()})
        a=a.subs(D)
        r0=mc.find_degree(T,s) 
        row_degrees=mc.row_degrees(T,s)                               
        i0=row_degrees.index(max(row_degrees))
        ast=Matrix(1,T.rows,[a[i]*s**(r0-row_degrees[i]) for i in range(T.rows)])
        #pprint (ast)
        TL=eye(T.rows)
        TL[i0*TL.cols]=ast
        #pprint (TL)
        T=TL*T
        T.simplify()
        Transfomation_Matrix=TL*Transfomation_Matrix
        Transfomation_Matrix.simplify()
        #pprint (T)
        #print('----------------------------')
            
    return  Transfomation_Matrix,T
Beispiel #2
0
def test_Matrix2():
    m = Matrix([[x, x**2], [5, 2/x]])
    assert (matrix(m.subs(x, 2)) == matrix([[2, 4], [5, 1]])).all()
    m = Matrix([[sin(x), x**2], [5, 2/x]])
    assert (matrix(m.subs(x, 2)) == matrix([[sin(2), 4], [5, 1]])).all()
Beispiel #3
0
def test_Matrix1():
    m = Matrix([[x, x**2], [5, 2/x]])
    assert (array(m.subs(x, 2)) == array([[2, 4], [5, 1]])).all()
    m = Matrix([[sin(x), x**2], [5, 2/x]])
    assert (array(m.subs(x, 2)) == array([[sin(2), 4], [5, 1]])).all()