#NEWLINE# def eval_evec( symmetric , d , typ , k , which , v0 = None , sigma = None , mattype = np . asarray , OPpart = None , mode = 'normal' ) : #NEWLINE# #INDENT# general = ( 'bmat' in d ) #NEWLINE# if symmetric : #NEWLINE# #INDENT# eigs_func = eigsh #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# eigs_func = eigs #NEWLINE# #UNINDENT# if general : #NEWLINE# #INDENT# err = ( 'error for %s:general, typ=%s, which=%s, sigma=%s, mattype=%s, OPpart=%s, mode=%s' % ( eigs_func . __name__ , typ , which , sigma , mattype . __name__ , OPpart , mode ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# err = ( 'error for %s:standard, typ=%s, which=%s, sigma=%s, mattype=%s, OPpart=%s, mode=%s' % ( eigs_func . __name__ , typ , which , sigma , mattype . __name__ , OPpart , mode ) ) #NEWLINE# #UNINDENT# a = d [ 'mat' ] . astype ( typ ) #NEWLINE# ac = mattype ( a ) #NEWLINE# if general : #NEWLINE# #INDENT# b = d [ 'bmat' ] . astype ( typ . lower ( ) ) #NEWLINE# bc = mattype ( b ) #NEWLINE# #UNINDENT# exact_eval = d [ 'eval' ] . astype ( typ . upper ( ) ) #NEWLINE# ind = argsort_which ( exact_eval , typ , k , which , sigma , OPpart , mode ) #NEWLINE# exact_eval = exact_eval [ ind ] #NEWLINE# kwargs = dict ( which = which , v0 = v0 , sigma = sigma ) #NEWLINE# if ( eigs_func is eigsh ) : #NEWLINE# #INDENT# kwargs [ 'mode' ] = mode #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ 'OPpart' ] = OPpart #NEWLINE# #UNINDENT# ( kwargs [ 'tol' ] , rtol , atol ) = _get_test_tolerance ( typ , mattype ) #NEWLINE# ntries = 0 #NEWLINE# while ( ntries < 5 ) : #NEWLINE# #INDENT# if general : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( eval , evec ) = eigs_func ( ac , k , bc , ** kwargs ) #NEWLINE# #UNINDENT# except ArpackNoConvergence : #NEWLINE# #INDENT# kwargs [ 'maxiter' ] = ( 20 * a . shape [ 0 ] ) #NEWLINE# ( eval , evec ) = eigs_func ( ac , k , bc , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# ( eval , evec ) = eigs_func ( ac , k , ** kwargs ) #NEWLINE# #UNINDENT# except ArpackNoConvergence : #NEWLINE# #INDENT# kwargs [ 'maxiter' ] = ( 20 * a . shape [ 0 ] ) #NEWLINE# ( eval , evec ) = eigs_func ( ac , k , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# ind = argsort_which ( eval , typ , k , which , sigma , OPpart , mode ) #NEWLINE# eval = eval [ ind ] #NEWLINE# evec = evec [ : , ind ] #NEWLINE# LHS = np . dot ( a , evec ) #NEWLINE# if general : #NEWLINE# #INDENT# RHS = ( eval * np . dot ( b , evec ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# RHS = ( eval * evec ) #NEWLINE# assert_allclose ( LHS , RHS , rtol = rtol , atol = atol , err_msg = err ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# assert_allclose_cc ( eval , exact_eval , rtol = rtol , atol = atol , err_msg = err ) #NEWLINE# break #NEWLINE# #UNINDENT# except AssertionError : #NEWLINE# #INDENT# ntries += 1 #NEWLINE# #UNINDENT# #UNINDENT# assert_allclose_cc ( eval , exact_eval , rtol = rtol , atol = atol , err_msg = err )