import numpy as np from PhysConst import PhysicsConstants def eigenvectors(M): """ Calculates the eigenvectors and eigenvalues ordered by eigenvalue size @type M : matrix @param M : matrix M @rtype : list @return : [eigenvalues list, eigenvector list] """ D,V = np.linalg.eig(M) DV = [] VT = V.T for i,eigenvalue in enumerate(D): DV.append([eigenvalue,VT[i]]) DV = sorted(DV,key = lambda x : x[0].real)#np.abs(x[0].real)) V2 = [] D2 = [] for e in DV: V2.append(e[1]) D2.append(e[0]) return D2,V2 # General Rotation Matrix def R(i,j,cp,param): """ Rotation Matrix Calculates the R_ij rotations. Also incorporates CP-phases when necesary. @type i : int @param i : i-column. @type j : int @param j : j-row. @type cp : int @param cp : if cp = 0 : no CP-phase. else CP-phase = CP_array[cp] @rtype : numpy.array @return : returns the R_ij rotation matrix. """ # if cp = 0 -> no complex phase # R_ij, i