r"""Compute eigenvectors of transition matrix.

    Parameters
    ----------
    T : (M, M) scipy.sparse matrix
        Transition matrix (stochastic matrix)
    k : int
        Number of eigenvalues to compute
    right : bool, optional
        If True compute right eigenvectors, left eigenvectors otherwise
    ncv : int, optional
        The number of Lanczos vectors generated, `ncv` must be greater than k;
        it is recommended that ncv > 2*k

    Returns
    -------
    eigvec : (M, k) ndarray
        k-eigenvectors of T

def eigenvectors_nrev(T, k, right=True, ncv=None):
    r"""Compute eigenvectors of transition matrix.

    Parameters
    ----------
    T : (M, M) scipy.sparse matrix
        Transition matrix (stochastic matrix)
    k : int
        Number of eigenvalues to compute
    right : bool, optional
        If True compute right eigenvectors, left eigenvectors otherwise
    ncv : int, optional
        The number of Lanczos vectors generated, `ncv` must be greater than k;
        it is recommended that ncv > 2*k

    Returns
    -------
    eigvec : (M, k) ndarray
        k-eigenvectors of T

    """
    if right:
        val, vecs = scipy.sparse.linalg.eigs(T, k=k, which='LM', ncv=ncv)
        ind = np.argsort(np.abs(val))[::-1]
        return vecs[:, ind]
    else:
        val, vecs = scipy.sparse.linalg.eigs(T.transpose(), k=k, which='LM', ncv=ncv)
        ind = np.argsort(np.abs(val))[::-1]
        return vecs[:, ind]