mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 20:13:41 +02:00
rtruediv implemented for CObs, tests extended
This commit is contained in:
parent
c634d183a1
commit
325293f2b4
3 changed files with 27 additions and 11 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue