r"""Compute eigenvectors of transition matrix.

    Parameters
    ----------
    T : (d, d) ndarray
        Transition matrix (stochastic matrix)
    k : int or tuple of ints, optional
        Compute the first k eigenvalues of T
    right : bool, optional
        If right=True compute right eigenvectors, left eigenvectors
        otherwise

    Returns
    -------
    eigvec : (d, d) ndarray
        The eigenvectors of T ordered with decreasing absolute value
        of the corresponding eigenvalue

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

    Parameters
    ----------
    T : (d, d) ndarray
        Transition matrix (stochastic matrix)
    k : int or tuple of ints, optional
        Compute the first k eigenvalues of T
    right : bool, optional
        If right=True compute right eigenvectors, left eigenvectors
        otherwise

    Returns
    -------
    eigvec : (d, d) ndarray
        The eigenvectors of T ordered with decreasing absolute value
        of the corresponding eigenvalue

    """
    if right:
        val, R = eig(T, left=False, right=True)
        """ Sorted eigenvalues and left and right eigenvectors. """
        perm = np.argsort(np.abs(val))[::-1]
        # eigval=val[perm]
        eigvec = R[:, perm]

    else:
        val, L = eig(T, left=True, right=False)

        """ Sorted eigenvalues and left and right eigenvectors. """
        perm = np.argsort(np.abs(val))[::-1]
        # eigval=val[perm]
        eigvec = L[:, perm]
    return eigvec