def __init__(self, evals, exclude_zeros=False):
        '''Initialize with array/list of eigenvalues or Intervals object.'''
        if isinstance(evals, Intervals):
            evals = [evals.min(), evals.max()]
            if evals[0] <= 0:
                raise AssumptionError(
                    'non-positive eigenvalues not allowed with intervals')

        # empty spectrum?
        if len(evals) == 0:
            raise AssumptionError('empty spectrum not allowed')

        # all evals real?
        if not numpy.isreal(evals).all():
            raise AssumptionError('non-real eigenvalues not allowed')

        # sort
        evals = numpy.sort(numpy.array(evals, dtype=numpy.float))

        # normalize
        evals /= evals[-1]

        if exclude_zeros is False and not (evals > 1e-15).all():
            raise AssumptionError(
                'non-positive eigenvalues not allowed (use exclude_zeros?)')

        # check that all are non-negative
        assert(evals[0] > -1e-15)

        # compute effective condition number
        kappa = 1/numpy.min(evals[evals > 1e-15])
        self.base = (numpy.sqrt(kappa)-1) / (numpy.sqrt(kappa)+1)
def __init__ ( self , evals , exclude_zeros = False ) : if isinstance ( evals , Intervals ) : evals = [ evals . min ( ) , evals . max ( ) ] if evals [ 0 ] <= 0 : raise AssumptionError ( 'non-positive eigenvalues not allowed with intervals' ) if len ( evals ) == 0 : raise AssumptionError ( 'empty spectrum not allowed' ) if not numpy . isreal ( evals ) . all ( ) : raise AssumptionError ( 'non-real eigenvalues not allowed' ) evals = numpy . sort ( numpy . array ( evals , dtype = numpy . float ) ) evals /= evals [ - 1 ] if exclude_zeros is False and not ( evals > 1e-15 ) . all ( ) : raise AssumptionError ( 'non-positive eigenvalues not allowed (use exclude_zeros?)' ) assert ( evals [ 0 ] > - 1e-15 ) kappa = 1 / numpy . min ( evals [ evals > 1e-15 ] ) self . base = ( numpy . sqrt ( kappa ) - 1 ) / ( numpy . sqrt ( kappa ) + 1 )
Initialize with array/list of eigenvalues or Intervals object.