'Return eigenvalues using the Berkowitz agorithm to compute
the characteristic polynomial.
Parameters
error_when_incomplete : bool
Raise an error when not all eigenvalues are computed. This is
caused by ``roots`` not returning a full list of eigenvalues.
Since the roots routine doesn\'t always work well with Floats,
they will be replaced with Rationals before calling that
routine. If this is not desired, set flag ``rational`` to False.'

def eigenvals(self, error_when_incomplete=True, **flags):

    mat = self
    if (not mat):
        return {}
    if flags.pop('rational', True):
        if any((v.has(Float) for v in mat)):
            mat = mat.applyfunc((lambda x: nsimplify(x, rational=True)))
    flags.pop('simplify', None)
    eigs = roots(mat.charpoly(x=Dummy('x')), **flags)
    if (error_when_incomplete and (sum((m for m in eigs.values())) != self.cols)):
        raise MatrixError('Could    not    compute    eigenvalues    for    {}'.format(self))
    return eigs
