From d11d7528e591336e3cb5a3f8c47312c4f6d22a25 Mon Sep 17 00:00:00 2001 From: shivesh Date: Wed, 28 Feb 2018 12:13:24 -0600 Subject: Initial Commit --- plot_llh/MinimalTools.py | 166 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 plot_llh/MinimalTools.py (limited to 'plot_llh/MinimalTools.py') diff --git a/plot_llh/MinimalTools.py b/plot_llh/MinimalTools.py new file mode 100644 index 0000000..4ae8360 --- /dev/null +++ b/plot_llh/MinimalTools.py @@ -0,0 +1,166 @@ +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