gh-117999: fixed small nonnegative integer powers of complex numbers#118000
gh-117999: fixed small nonnegative integer powers of complex numbers#118000skirpichev wants to merge 13 commits intopython:mainfrom
Conversation
2a6babf to
5ee43ee
Compare
51c6cad to
cd3e11e
Compare
…mbers
Before, handling of numbers with special values in components
(infinities, nans, signed zero) was invalid. Simple example:
>>> z = complex(1, -0.0)
>>> z*z
(1-0j)
>>> z**2
(1+0j)
Now:
>>> z**2
(1-0j)
58c2fb1 to
8e0c482
Compare
|
@picnixz, I would appreciate your review on this pr. Or your opinion in the issue thread. |
|
I'll do it tomorrow! (Monday, Paris time) |
|
I need to think a bit more on the issue. I'll try to have something by the end of the day or tomorrow. Ideally, I would like to have no inconsistency between the generic algorithm and the non-generic one (namely, the result should be as if we were using the generic algorithm). |
I'm not sure if it's possible without too much code, that affects performance severely. BTW, I think that numpy code has no such special version for integer exponents. I'll double check. Edit: Ah, no. numpy mimics CPython here, at least in npy_math_complex.c.src. Edit2: JFR, some simple benchmarks. With specialized code (main): Without: |
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Before, handling of numbers with special values in components (infinities, nans, signed zero) was invalid. Simple example:
>>> z = complex(1, -0.0) >>> z*z (1-0j) >>> z**2 (1+0j)Now:
>>> z**2 (1-0j)