

def schur(a, output='real', lwork=None, overwrite_a=False, sort=None, check_finite=True):
    "\n    Compute Schur decomposition of a matrix.\n\n    The Schur decomposition is::\n\n        A = Z T Z^H\n\n    where Z is unitary and T is either upper-triangular, or for real\n    Schur decomposition (output='real'), quasi-upper triangular.  In\n    the quasi-triangular form, 2x2 blocks describing complex-valued\n    eigenvalue pairs may extrude from the diagonal.\n\n    Parameters\n    ----------\n    a : (M, M) array_like\n        Matrix to decompose\n    output : {'real', 'complex'}, optional\n        Construct the real or complex Schur decomposition (for real matrices).\n    lwork : int, optional\n        Work array size. If None or -1, it is automatically computed.\n    overwrite_a : bool, optional\n        Whether to overwrite data in a (may improve performance).\n    sort : {None, callable, 'lhp', 'rhp', 'iuc', 'ouc'}, optional\n        Specifies whether the upper eigenvalues should be sorted.  A callable\n        may be passed that, given a eigenvalue, returns a boolean denoting\n        whether the eigenvalue should be sorted to the top-left (True).\n        Alternatively, string parameters may be used::\n\n            'lhp'   Left-hand plane (x.real < 0.0)\n            'rhp'   Right-hand plane (x.real > 0.0)\n            'iuc'   Inside the unit circle (x*x.conjugate() <= 1.0)\n            'ouc'   Outside the unit circle (x*x.conjugate() > 1.0)\n\n        Defaults to None (no sorting).\n    check_finite : bool, optional\n        Whether to check that the input matrix contains only finite numbers.\n        Disabling may give a performance gain, but may result in problems\n        (crashes, non-termination) if the inputs do contain infinities or NaNs.\n\n    Returns\n    -------\n    T : (M, M) ndarray\n        Schur form of A. It is real-valued for the real Schur decomposition.\n    Z : (M, M) ndarray\n        An unitary Schur transformation matrix for A.\n        It is real-valued for the real Schur decomposition.\n    sdim : int\n        If and only if sorting was requested, a third return value will\n        contain the number of eigenvalues satisfying the sort condition.\n\n    Raises\n    ------\n    LinAlgError\n        Error raised under three conditions:\n\n        1. The algorithm failed due to a failure of the QR algorithm to\n           compute all eigenvalues\n        2. If eigenvalue sorting was requested, the eigenvalues could not be\n           reordered due to a failure to separate eigenvalues, usually because\n           of poor conditioning\n        3. If eigenvalue sorting was requested, roundoff errors caused the\n           leading eigenvalues to no longer satisfy the sorting condition\n\n    See also\n    --------\n    rsf2csf : Convert real Schur form to complex Schur form\n\n    "
    if (output not in ['real', 'complex', 'r', 'c']):
        raise ValueError("argument must be 'real', or 'complex'")
    if check_finite:
        a1 = asarray_chkfinite(a)
    else:
        a1 = asarray(a)
    if ((len(a1.shape) != 2) or (a1.shape[0] != a1.shape[1])):
        raise ValueError('expected square matrix')
    typ = a1.dtype.char
    if ((output in ['complex', 'c']) and (typ not in ['F', 'D'])):
        if (typ in _double_precision):
            a1 = a1.astype('D')
            typ = 'D'
        else:
            a1 = a1.astype('F')
            typ = 'F'
    overwrite_a = (overwrite_a or _datacopied(a1, a))
    (gees,) = get_lapack_funcs(('gees',), (a1,))
    if ((lwork is None) or (lwork == (- 1))):
        result = gees((lambda x: None), a1, lwork=(- 1))
        lwork = result[(- 2)][0].real.astype(numpy.int)
    if (sort is None):
        sort_t = 0
        sfunction = (lambda x: None)
    else:
        sort_t = 1
        if callable(sort):
            sfunction = sort
        elif (sort == 'lhp'):
            sfunction = (lambda x: (numpy.real(x) < 0.0))
        elif (sort == 'rhp'):
            sfunction = (lambda x: (numpy.real(x) >= 0.0))
        elif (sort == 'iuc'):
            sfunction = (lambda x: (abs(x) <= 1.0))
        elif (sort == 'ouc'):
            sfunction = (lambda x: (abs(x) > 1.0))
        else:
            raise ValueError(('sort parameter must be None, a callable, or ' + "one of ('lhp','rhp','iuc','ouc')"))
    result = gees(sfunction, a1, lwork=lwork, overwrite_a=overwrite_a, sort_t=sort_t)
    info = result[(- 1)]
    if (info < 0):
        raise ValueError(('illegal value in %d-th argument of internal gees' % (- info)))
    elif (info == (lwork.shape[0] + 1)):
        raise LinAlgError('Eigenvalues could not be separated for reordering.')
    elif (info == (a1.shape[0] + 2)):
        raise LinAlgError('Leading eigenvalues do not satisfy sort condition.')
    elif (info > 0):
        raise LinAlgError('Schur form not found.  Possibly ill-conditioned.')
    if (sort_t == 0):
        return (result[0], result[(- 3)])
    else:
        return (result[0], result[(- 3)], result[1])

dataset/ETHPy150Open scipy/scipy/scipy/linalg/decomp_schur.py schur/VarMisuse@519/1776 `a1`->`lwork`