-
Notifications
You must be signed in to change notification settings - Fork 205
Description
I think, we should implement mixed-mode rules for complex arithmetic. Partially, this already acomplished: mpmath has special rules for mpf op mpc cases, for instance mpc_mul_mpf() to multiply a complex z by a real number r component-wise, z*r == mpc(z.real*r, z.imag*r).
But I'm not sure if that implementation is complete, and obviously it has many bugs. A quick example:
>>> 1/mpc(inf, 1)
mpc(real='nan', imag='0.0')
>>> 1/complex('(inf+1j)')
0jThis case is worse than CPython, probably just due to using naive algorithm for complex division (instead of something like Smith's version).
Entirely missing component is an imaginary type, i.e. one that has only imaginary component and no real. See draft CPython proposal: skirpichev/cpython#1
It should be noted, that this issue depends on #167: presence of signed zeros provide more "corner cases" for analytic expressions (like asinh(z)=log(z + sqrt(1 + z**2))). But regardless on this, we already have infinities, that will require special treatment.