diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index a7f16cb8..aedf0e54 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -3,6 +3,7 @@ import autograd.numpy as anp #from scipy.special.orthogonal import _IntegerType from .pyerrors import * from .fits import standard_fit +from .linalg import * from .roots import find_root from matplotlib import pyplot as plt from matplotlib.ticker import NullFormatter # useful for `logit` scale @@ -23,7 +24,7 @@ class Corr: """ - def __init__(self, data_input, padding_front=0, padding_back=0,range=None): + def __init__(self, data_input, padding_front=0, padding_back=0,prange=None): #All data_input should be a list of things at different timeslices. This needs to be verified if not (isinstance(data_input, list)): @@ -61,7 +62,7 @@ class Corr: #This is useful for keeping track of plateaus and fitranges. #The range can be inherited from other Corrs, if the operation should not alter a chosen range eg. multiplication with a constant. if not range is None: - self.range=range + self.prange=prange self.gamma_method() @@ -143,7 +144,7 @@ class Corr: if(all([x is None for x in newcontent])): raise Exception("Corr could not be symmetrized: No redundant values") - return Corr(newcontent,range= self.range if hasattr(self,"range") else None) + return Corr(newcontent,prange= self.prange if hasattr(self,"prange") else None) def anti_symmetric(self): @@ -158,7 +159,7 @@ class Corr: newcontent.append(0.5 * (self.content[t] - self.content[self.T - t])) if(all([x is None for x in newcontent])): raise Exception("Corr could not be symmetrized: No redundant values") - return Corr(newcontent,range= self.range if hasattr(self,"range") else None) + return Corr(newcontent,prange= self.prange if hasattr(self,"prange") else None) #This method will symmetrice the matrices and therefore make them positive definit. @@ -186,6 +187,32 @@ class Corr: return sp_vec + def Eigenvalue(self,t0,state=1): + G=self.smearing_symmetric() + G0=G.content[t0] + L = mat_mat_op(anp.linalg.cholesky, G0) + Li = mat_mat_op(anp.linalg.inv, L) + LT=L.T + LTi=mat_mat_op(anp.linalg.inv, LT) + newcontent=[] + for t in range(self.T): + Gt=G.content[t] + M=Li@Gt@LTi + eigenvalues = eigh(M)[0] + #print(eigenvalues) + eigenvalue=eigenvalues[-state] + newcontent.append(eigenvalue) + return Corr(newcontent) + + + + + + + + + + def roll(self, dt): return Corr(list(np.roll(np.array(self.content, dtype=object), dt))) @@ -260,6 +287,17 @@ class Corr: raise Exception('m_eff is undefined at all timeslices') return Corr(newcontent, padding_back=1) + elif variant is 'arccosh': + newcontent=[] + for t in range(1,self.T-1): + if (self.content[t] is None) or (self.content[t+1] is None)or (self.content[t-1] is None): + newcontent.append(None) + else: + newcontent.append((self.content[t+1]+self.content[t-1])/(2*self.content[t])) + if(all([x is None for x in newcontent])): + raise Exception("m_eff is undefined at all timeslices") + return np.arccosh(Corr(newcontent,padding_back=1,padding_front=1)) + else: raise Exception('Unkown variant.') @@ -275,8 +313,8 @@ class Corr: if fitrange is None: - if hasattr(self,"range"): - fitrange=self.range + if hasattr(self,"prange"): + fitrange=self.prange else: fitrange=[0, self.T] @@ -294,8 +332,8 @@ class Corr: #we want to quickly get a plateau def plateau(self, plateau_range=None, method="fit"): if not plateau_range: - if hasattr(self,"range"): - plateau_range=self.range + if hasattr(self,"prange"): + plateau_range=self.prange else: raise Exception("no plateau range provided") if self.N != 1: @@ -316,15 +354,15 @@ class Corr: - def set_range(self,range): - if not len(range)==2: + def set_prange(self,prange): + if not len(prange)==2: raise Exception("range must be a list or array with two values") - if not ((isinstance(range[0],int)) and (isinstance(range[1],int))): + if not ((isinstance(prange[0],int)) and (isinstance(prange[1],int))): raise Exception("start and end point must be integers") - if not (0<=range[0]<=self.T and 0<=range[1]<=self.T and range[0]