def chebcompanion(c):
<EOL>[c] = pu.as_series([c])<EOL>if len(c) < <NUM_LIT:2>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>if len(c) == <NUM_LIT:2>:<EOL><INDENT>return np.array([[-c[<NUM_LIT:0>]/c[<NUM_LIT:1>]]])<EOL><DEDENT>n = len(c) - <NUM_LIT:1><EOL>mat = np.zeros((n, n), dtype=c.dtype)<EOL>scl = np.array([<NUM_LIT:1.>] + [np.sqrt(<NUM_LIT>)]*(n-<NUM_LIT:1>))<EOL>top = mat.reshape(-<NUM_LIT:1>)[<NUM_LIT:1>::n+<NUM_LIT:1>]<EOL>bot = mat.reshape(-<NUM_LIT:1>)[n::n+<NUM_LIT:1>]<EOL>top[<NUM_LIT:0>] = np.sqrt(<NUM_LIT>)<EOL>top[<NUM_LIT:1>:] = <NUM_LIT:1>/<NUM_LIT:2><EOL>bot[...] = top<EOL>mat[:, -<NUM_LIT:1>] -= (c[:-<NUM_LIT:1>]/c[-<NUM_LIT:1>])*(scl/scl[-<NUM_LIT:1>])*<NUM_LIT><EOL>return mat<EOL>
Return the scaled companion matrix of c.

    The basis polynomials are scaled so that the companion matrix is
    symmetric when `c` is aa Chebyshev basis polynomial. This provides
    better eigenvalue estimates than the unscaled case and for basis
    polynomials the eigenvalues are guaranteed to be real if
    `numpy.linalg.eigvalsh` is used to obtain them.

    Parameters
    ----------
    c : array_like
        1-D array of Chebyshev series coefficients ordered from low to high
        degree.

    Returns
    -------
    mat : ndarray
        Scaled companion matrix of dimensions (deg, deg).

    Notes
    -----

    .. versionadded::1.7.0