def eigenvalues(T, k=None, ncv=None, reversible=False, mu=None):
    r"""Compute the eigenvalues of a sparse transition matrix.

    Parameters
    ----------
    T : (M, M) scipy.sparse matrix
        Transition matrix
    k : int, optional
        Number of eigenvalues to compute.
    ncv : int, optional
        The number of Lanczos vectors generated, `ncv` must be greater than k;
        it is recommended that ncv > 2*k
    reversible : bool, optional
        Indicate that transition matrix is reversible
    mu : (M,) ndarray, optional
        Stationary distribution of T

    Returns
    -------
    v : (k,) ndarray
        Eigenvalues of T

    Notes
    -----
    The first k eigenvalues of largest magnitude are computed.

    If reversible=True the the eigenvalues of the similar symmetric
    matrix `\sqrt(\mu_i / \mu_j) p_{ij}` will be computed.

    The precomputed stationary distribution will only be used if
    reversible=True.

    """
    if k is None:
        raise ValueError("Number of eigenvalues required for decomposition of sparse matrix")
    else:
        if reversible:
            try:
                v = eigenvalues_rev(T, k, ncv=ncv, mu=mu)
            except:  # use fallback code, but cast to real
                v = scipy.sparse.linalg.eigs(T, k=k, which='LM', return_eigenvectors=False, ncv=ncv).real
        else:
            v = scipy.sparse.linalg.eigs(T, k=k, which='LM', return_eigenvectors=False, ncv=ncv)

    ind = np.argsort(np.abs(v))[::-1]
    return v[ind]
r"""Compute the eigenvalues of a sparse transition matrix.

    Parameters
    ----------
    T : (M, M) scipy.sparse matrix
        Transition matrix
    k : int, optional
        Number of eigenvalues to compute.
    ncv : int, optional
        The number of Lanczos vectors generated, `ncv` must be greater than k;
        it is recommended that ncv > 2*k
    reversible : bool, optional
        Indicate that transition matrix is reversible
    mu : (M,) ndarray, optional
        Stationary distribution of T

    Returns
    -------
    v : (k,) ndarray
        Eigenvalues of T

    Notes
    -----
    The first k eigenvalues of largest magnitude are computed.

    If reversible=True the the eigenvalues of the similar symmetric
    matrix `\sqrt(\mu_i / \mu_j) p_{ij}` will be computed.

    The precomputed stationary distribution will only be used if
    reversible=True.