mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 14:50:25 +01:00
npr doc extended, CObs now have real and imag properties
This commit is contained in:
parent
e7efa822b0
commit
7efe9612bc
2 changed files with 25 additions and 9 deletions
|
@ -38,7 +38,7 @@ class Npr_matrix(np.ndarray):
|
|||
if s_mom is not None and o_mom is not None:
|
||||
if not np.allclose(s_mom, o_mom):
|
||||
raise Exception(name + ' does not match.')
|
||||
return o_mom if o_mom else s_mom
|
||||
return o_mom if o_mom is not None else s_mom
|
||||
|
||||
def __matmul__(self, other):
|
||||
return self.__new__(Npr_matrix,
|
||||
|
@ -65,13 +65,23 @@ def _check_geometry():
|
|||
raise Exception("Temporal extent 'T' must be an integer.")
|
||||
|
||||
|
||||
def _invert_propagator(prop):
|
||||
def inv_propagator(prop):
|
||||
""" Inverts a 12x12 quark propagator"""
|
||||
if prop.shape != (12, 12):
|
||||
raise Exception("Only 12x12 propagators can be inverted.")
|
||||
return Npr_matrix(mat_mat_op(anp.linalg.inv, prop), prop.mom_in)
|
||||
|
||||
|
||||
def Zq(prop, fermion='Wilson'):
|
||||
def Zq(inv_prop, fermion='Wilson'):
|
||||
""" Calculates the quark field renormalization constant Zq
|
||||
|
||||
Attributes:
|
||||
inv_prop -- Inverted 12x12 quark propagator
|
||||
fermion -- Fermion type for which the tree-level propagator is used
|
||||
in the calculation of Zq. Default Wilson.
|
||||
"""
|
||||
_check_geometry()
|
||||
mom = np.copy(prop.mom_in)
|
||||
mom = np.copy(inv_prop.mom_in)
|
||||
mom[3] /= T / L
|
||||
sin_mom = np.sin(2 * np.pi / L * mom)
|
||||
|
||||
|
@ -80,8 +90,6 @@ def Zq(prop, fermion='Wilson'):
|
|||
else:
|
||||
raise Exception("Fermion type '" + fermion + "' not implemented")
|
||||
|
||||
inv_prop = _invert_propagator(prop)
|
||||
|
||||
res = 1 / 12. * np.trace(inv_prop @ np.kron(np.eye(3, dtype=int), p_slash))
|
||||
res.gamma_method()
|
||||
|
||||
|
|
|
@ -650,13 +650,21 @@ class Obs:
|
|||
|
||||
class CObs:
|
||||
"""Class for a complex valued observable."""
|
||||
__slots__ = ['real', 'imag', 'tag']
|
||||
__slots__ = ['_real', '_imag', 'tag']
|
||||
|
||||
def __init__(self, real, imag=0.0):
|
||||
self.real = real
|
||||
self.imag = imag
|
||||
self._real = real
|
||||
self._imag = imag
|
||||
self.tag = None
|
||||
|
||||
@property
|
||||
def real(self):
|
||||
return self._real
|
||||
|
||||
@property
|
||||
def imag(self):
|
||||
return self._imag
|
||||
|
||||
def gamma_method(self, **kwargs):
|
||||
if isinstance(self.real, Obs):
|
||||
self.real.gamma_method(**kwargs)
|
||||
|
|
Loading…
Add table
Reference in a new issue