Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- def characteristic_matrix(coeffs):
- n = coeffs.size-1
- A = np.eye(n, k=1);
- print -(1/coeffs[0]) * coeffs[-1:0:-1]
- A[-1,::] = -1 * (coeffs[-1:0:-1]/coeffs[0])
- return A
- def get_real_roots(coeffs):
- A=characteristic_matrix(coeffs)
- print A
- start = time.time()
- E,Q=np.linalg.eig(A)
- end = time.time()
- print "Solved in:"
- print end-start
- return E
- get_real_roots(np.array([-3.0, 0.0, 5.0, -1.0, 0.0])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement