rtruediv implemented for CObs, tests extended

This commit is contained in:
Fabian Joswig 2021-10-25 10:44:51 +01:00
parent c634d183a1
commit 325293f2b4
3 changed files with 27 additions and 11 deletions

View file

@ -95,4 +95,7 @@ def Zq(inv_prop, fermion='Wilson'):
if not res.imag.is_zero_within_error(5):
warnings.warn("Imaginary part of Zq is not zero within 5 sigma")
return res
if not np.abs(res.imag.value) <= 1e-6:
warnings.warn("Imaginary part of Zq is not smaller than 1e-6")
return res
return res.real

View file

@ -740,6 +740,13 @@ class CObs:
else:
return CObs(self.real / other, self.imag / other)
def __rtruediv__(self, other):
r = self.real ** 2 + self.imag ** 2
if hasattr(other, 'real') and hasattr(other, 'imag'):
return CObs((self.real * other.real + self.imag * other.imag) / r, (self.real * other.imag - self.imag * other.real) / r)
else:
return CObs(self.real * other / r, -self.imag * other / r)
def __abs__(self):
return np.sqrt(self.real**2 + self.imag**2)