import numpy as np import math a = 0.00333333 Q = np.array( [[ -3*a, a, a, a], [ a, -3*a, a, a], [ a, a, -3*a, a], [ a, a, a, -3*a]]) evals, evecs = np.linalg.eig(Q) U = evecs L = np.diag(evals) Ui = np.linalg.inv(U) temp = np.dot(U,L) P = np.dot(temp,Ui)
names = ['Q','evals','evecs','U','L','Ui','P'] for i,v in enumerate([Q,evals,evecs,U,L,Ui,P]): print names[i] for row in v: try: temp = [str(round(e,3)).rjust(5) for e in row] print ' '.join(temp) except: print row print |