Skip to content

zero() returns error if there are no zeros and slycot is installed #218

Description

@murrayrm

PR #205 added support for MIMO systems in the calculation of zeros for state space systems (using slycot), but there is a bug if there are no zeros in the input/output response.

To generate the bug, use

import control
s = control.ss( control.tf([1], [1, 2, 1]) )
s.zero()

Without slycot, we get

array([], dtype=float64)

With slycot (0.3.3) this generates the following error trace:

~/src/python-control/murrayrm/control/statesp.py in zero(self)
    526                          self.A, self.B, self.C, self.D)
    527             nu = out[0]
--> 528             return sp.linalg.eigvals(out[8][0:nu,0:nu], out[9][0:nu,0:nu])
    529         except ImportError:  # Slycot unavailable. Fall back to scipy.
    530             if self.C.shape[0] != self.D.shape[1]:

~/anaconda/envs/python3.6-slycot0.3.3/lib/python3.6/site-packages/scipy/linalg/decomp.py in eigvals(a, b, overwrite_a, check_finite, homogeneous_eigvals)
    767     return eig(a, b=b, left=0, right=0, overwrite_a=overwrite_a,
    768                check_finite=check_finite,
--> 769                homogeneous_eigvals=homogeneous_eigvals)
    770 
    771 

~/anaconda/envs/python3.6-slycot0.3.3/lib/python3.6/site-packages/scipy/linalg/decomp.py in eig(a, b, left, right, overwrite_a, overwrite_b, check_finite, homogeneous_eigvals)
    224             raise ValueError('a and b must have the same shape')
    225         return _geneig(a1, b1, left, right, overwrite_a, overwrite_b,
--> 226                        homogeneous_eigvals)
    227 
    228     geev, geev_lwork = get_lapack_funcs(('geev', 'geev_lwork'), (a1,))

~/anaconda/envs/python3.6-slycot0.3.3/lib/python3.6/site-packages/scipy/linalg/decomp.py in _geneig(a1, b1, left, right, overwrite_a, overwrite_b, homogeneous_eigvals)
     78     ggev, = get_lapack_funcs(('ggev',), (a1, b1))
     79     cvl, cvr = left, right
---> 80     res = ggev(a1, b1, lwork=-1)
     81     lwork = res[-2][0].real.astype(numpy.int)
     82     if ggev.typecode in 'cz':

ValueError: failed to create intent(cache|hide)|optional array-- must have defined dimensions but got (0,)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions