mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-03-15 23:00:25 +01:00
Bug in complex mutliplication fixed
This commit is contained in:
parent
94e3ebe7f0
commit
9b023e339f
1 changed files with 11 additions and 10 deletions
|
@ -714,6 +714,7 @@ class CObs:
|
||||||
return -1 * (self - other)
|
return -1 * (self - other)
|
||||||
|
|
||||||
def __mul__(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]):
|
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],
|
return CObs(derived_observable(lambda x, **kwargs: x[0] * x[1] - x[2] * x[3],
|
||||||
[self.real, other.real, self.imag, other.imag],
|
[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],
|
derived_observable(lambda x, **kwargs: x[2] * x[1] + x[0] * x[3],
|
||||||
[self.real, other.real, self.imag, other.imag],
|
[self.real, other.real, self.imag, other.imag],
|
||||||
man_grad=[other.imag.value, self.imag.value, other.real.value, self.real.value]))
|
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,
|
return CObs(self.real * other.real - self.imag * other.imag,
|
||||||
self.imag * other.real + self.real * other.imag)
|
self.imag * other.real + self.real * other.imag)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Reference in a new issue