def eigenvalues_auto(mat, n_eivals='<STR_LIT>'):
do_full = True<EOL>n_lower = <NUM_LIT><EOL>n_upper = <NUM_LIT><EOL>nv = mat.shape[<NUM_LIT:0>]<EOL>if n_eivals == '<STR_LIT>':<EOL><INDENT>if mat.shape[<NUM_LIT:0>] > <NUM_LIT>:<EOL><INDENT>do_full = False<EOL><DEDENT><DEDENT>if n_eivals == '<STR_LIT>':<EOL><INDENT>do_full = True<EOL><DEDENT>if isinstance(n_eivals, int):<EOL><INDENT>n_lower = n_upper = n_eivals<EOL>do_full = False<EOL><DEDENT>if isinstance(n_eivals, tuple):<EOL><INDENT>n_lower, n_upper = n_eivals<EOL>do_full = False<EOL><DEDENT>if do_full and sps.issparse(mat):<EOL><INDENT>mat = mat.todense()<EOL><DEDENT>if sps.issparse(mat):<EOL><INDENT>if n_lower == n_upper:<EOL><INDENT>tr_eivals = spsl.eigsh(mat, <NUM_LIT:2>*n_lower, which='<STR_LIT>', return_eigenvectors=False)<EOL>return updown_linear_approx(tr_eivals[:n_upper], tr_eivals[n_upper:], nv)<EOL><DEDENT>else:<EOL><INDENT>lo_eivals = spsl.eigsh(mat, n_lower, which='<STR_LIT>', return_eigenvectors=False)[::-<NUM_LIT:1>]<EOL>up_eivals = spsl.eigsh(mat, n_upper, which='<STR_LIT>', return_eigenvectors=False)<EOL>return updown_linear_approx(lo_eivals, up_eivals, nv)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if do_full:<EOL><INDENT>return spl.eigvalsh(mat)<EOL><DEDENT>else:<EOL><INDENT>lo_eivals = spl.eigvalsh(mat, eigvals=(<NUM_LIT:0>, n_lower-<NUM_LIT:1>))<EOL>up_eivals = spl.eigvalsh(mat, eigvals=(nv-n_upper-<NUM_LIT:1>, nv-<NUM_LIT:1>))<EOL>return updown_linear_approx(lo_eivals, up_eivals, nv)<EOL><DEDENT><DEDENT>
Automatically computes the spectrum of a given Laplacian matrix.

Parameters
----------
mat : numpy.ndarray or scipy.sparse
    Laplacian matrix
n_eivals : string or int or tuple
    Number of eigenvalues to compute / use for approximation.
    If string, we expect either 'full' or 'auto', otherwise error will be raised. 'auto' lets the program decide based on the faithful usage. 'full' computes all eigenvalues.
    If int, compute n_eivals eigenvalues from each side and approximate using linear growth approximation.
    If tuple, we expect two ints, first for lower part of approximation, and second for the upper part.

Returns
-------
np.ndarray
    Vector of approximated eigenvalues

Examples
--------
>>> eigenvalues_auto(numpy.array([[ 2, -1, -1], [-1,  2, -1], [-1, -1,  2]]), 'auto')
array([0, 3, 3])