BUG: Invalid corner cases (resulting in nan+nanj) in complex division · Issue #26560 · numpy/numpy · GitHub
Skip to content

BUG: Invalid corner cases (resulting in nan+nanj) in complex division #26560

Description

@skirpichev

Describe the issue:

It seems, that numpy uses Smith's algorithm to do complex true division. In some cases (see below) it produces (nan+nanj), but meaningful components could be recovered. See e.g. C11 Annex G.5.2, _Cdivd()'s example.

FYI: see also CPython's issue python/cpython#119372

Reproduce the code example:

>>> 1/np.complex128('inf')
0j
>>> 1/np.complex128('infj')
-0j
>>> 1/np.complex128('(inf+infj)')  # oops, should be 0j
<stdin>:1: RuntimeWarning: invalid value encountered in scalar divide
(nan+nanj)

Error message:

No response

Python and NumPy Versions:

>>> np.__version__
'1.26.4'

Runtime Environment:

No response

Context for the issue:

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions