Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.40 KB | None | 0 0
  1. def characteristic_matrix(coeffs):
  2.     n = coeffs.size-1
  3.     A = np.eye(n, k=1);
  4.  
  5.     print -(1/coeffs[0]) * coeffs[-1:0:-1]
  6.     A[-1,::] = -1 * (coeffs[-1:0:-1]/coeffs[0])
  7.     return A
  8.  
  9. def get_real_roots(coeffs):
  10.     A=characteristic_matrix(coeffs)
  11.     print A
  12.     start = time.time()
  13.     E,Q=np.linalg.eig(A)
  14.     end = time.time()
  15.  
  16.     print "Solved in:"
  17.     print end-start
  18.  
  19.     return E
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement