Bug in complex mutliplication fixed

This commit is contained in:
Fabian Joswig 2021-10-25 09:41:34 +01:00
parent 94e3ebe7f0
commit 9b023e339f

View file

@ -714,6 +714,7 @@ class CObs:
return -1 * (self - other)
def __mul__(self, other):
if hasattr(other, 'real') and getattr(other, 'imag', 0) != 0:
if all(isinstance(i, Obs) for i in [self.real, self.imag, other.real, other.imag]):
return CObs(derived_observable(lambda x, **kwargs: x[0] * x[1] - x[2] * x[3],
[self.real, other.real, self.imag, other.imag],
@ -721,7 +722,7 @@ class CObs:
derived_observable(lambda x, **kwargs: x[2] * x[1] + x[0] * x[3],
[self.real, other.real, self.imag, other.imag],
man_grad=[other.imag.value, self.imag.value, other.real.value, self.real.value]))
elif hasattr(other, 'real') and getattr(other, 'imag', 0) != 0:
else:
return CObs(self.real * other.real - self.imag * other.imag,
self.imag * other.real + self.real * other.imag)
else: