ilayn/harold

zero dynamics within MIMO transfer functions leads to errors

ilayn opened this issue · 2 comments

If a transfer matrix involves scalars, e.g.,

    [    |    1   ]
G = [  1 |  ----- ]
    [    |   s+1  ]

after the separation of the feed-through, still treated as a polynomial entry and looks for least common denominators.

Extra check is necessary for empty dynamics in entries.

Moreover, tf(5), ss(5) still causes problems.

Needs a proper gateway to be written to account for these.

Offending input was

G = tf([[[1,1],[1,1]],[[1],[1,2,1]]],[[[1,2],[1,5,6]],[[1],[1,7,10]]])

However, state representation has no problems

    A = blkdiag([-2],[[-5,-3],[2,0]],[-5])
    B = np.array([[1,0,0,0],[0,1,0,1]]).T
    C = np.array([[-1,1,0.5,0],[0,0,0,1]])
    D = np.array([[1,0],[1,0]])
    G2 = ss(A,B,C,D)

It leads to

 Continous-time state represantation
 2 input(s) and 2 output(s)

Poles(real)    Poles(imag)    Zeros(real)    Zeros(imag)
-------------  -------------  -------------  -------------
         -2              0             -1             -0
         -3              0             -2             -0
         -2              0
         -5              0

But conversion to transfer, gives nonsense zeros due to wrong initialization

G2tf = tf(*ss2tf(G2))

Numpy's polynomial module has this strange coefficient reversal behavior and I was using it before I gave up and wrapped harold's own functions. Thus there were a lot of array reversal points involving a[::-1] type of coding.

It seems that while I was removing the numpy.polynomial.polynomial dependence, I have removed one too many and the C matrix coefficients were entering in the reversed order. Now, after some testing, looks like it is fixed.