def tridi_inverse_iteration(d, e, w, x0=None, rtol=1e-08):
 eig_diag = (d - w)
 if (x0 is None):
  x0 = np.random.randn(len(d))
 x_prev = np.zeros_like(x0)
 norm_x = np.linalg.norm(x0)
 x0 /= norm_x
 while (np.linalg.norm((np.abs(x0) - np.abs(x_prev))) > rtol):
  x_prev = x0.copy()
  tridisolve(eig_diag, e, x0)
  norm_x = np.linalg.norm(x0)
  x0 /= norm_x
 return x0

def tridi_inverse_iteration ( d , e , w , x0 = None , rtol = 1e-08 ) : eig_diag = ( d - w ) if ( x0 is None ) : x0 = np . random . randn ( len ( d ) ) x_prev = np . zeros_like ( x0 ) norm_x = np . linalg . norm ( x0 ) x0 /= norm_x while ( np . linalg . norm ( ( np . abs ( x0 ) - np . abs ( x_prev ) ) ) > rtol ) : x_prev = x0 . copy ( ) tridisolve ( eig_diag , e , x0 ) norm_x = np . linalg . norm ( x0 ) x0 /= norm_x return x0
perform an inverse iteration .