Advertisement
Guest User

Untitled

a guest
May 20th, 2019
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. def MSI(A,b,eps):
  2.     if not np.all(np.linalg.eigvals(A) > 0):
  3.         T = A
  4.         A = np.transpose(T).dot(A)
  5.         b = np.transpose(T).dot(A)
  6.  
  7.     mu = 2/(np.linalg.norm(A) + eps)
  8.     B = np.eye(A.shape[0]) - mu * A
  9.     c = mu*b
  10.     xcur = np.random.random(A.shape[0])
  11.     xcur = np.reshape(xcur, (3,1))
  12.     xnext = B@xcur + c
  13.    
  14.    
  15.     while (np.linalg.norm(xcur - xnext) > eps):
  16.         xcur = xnext
  17.         xnext = B.dot(xcur) + c
  18.     return xnext
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement