Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

charris
Copy link
Member

@charris charris commented Aug 2, 2025

Backport of #29333.

Addresses gh-18304.

The condition number of a matrix is the product of two norms, which are
always non-negative and real-valued, so the condition number itself
should be non-negative and real-valued. This commit returns the proper
real dtype from linalg.cond, and includes tests for the condition
number of a complex matrix in various norms.

The existing docstring for linalg.cond already states that the return value is
either a float or inf, so the function behavior is now consistent with the
docstring.

  • BUG: Always return a real dtype from linalg.cond.

Addresses gh-18304.

The condition number of a matrix is the product of two norms, which are always non-negative and real-valued, so the condition number itself should be non-negative and real-valued. This commit returns the proper real dtype from linalg.cond, and includes tests for the condition number of a complex matrix in various norms.

  • ENH: Change type of complex results only.

This commit addresses a reviewer comment on the blanket application of abs(r). It specifically ensures the return type of complex-valued matrices will be the corresponding real type.

…py#29333)

* BUG: Always return a real dtype from linalg.cond.

Addresses numpygh-18304.

The condition number of a matrix is the product of two norms, which are
always non-negative and real-valued, so the condition number itself
should be non-negative and real-valued. This commit returns the proper
real dtype from `linalg.cond`, and includes tests for the condition
number of a complex matrix in various norms.

* ENH: Change type of complex results only.

This commit addresses a reviewer comment on the blanket application of
`abs(r)`. It specifically ensures the return type of complex-valued
matrices will be the corresponding real type.
@charris charris added this to the 2.3.3 release milestone Aug 2, 2025
@charris charris added 00 - Bug 08 - Backport Used to tag backport PRs labels Aug 2, 2025
@charris charris merged commit c6eac44 into numpy:maintenance/2.3.x Aug 2, 2025
75 checks passed
@charris charris deleted the backport-29333 branch August 2, 2025 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
00 - Bug 08 - Backport Used to tag backport PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants