Skip to content

Support 'nuc' norm in dpnp.linalg.cond - #3084

Open
antonwolfy wants to merge 3 commits into
masterfrom
support-nuc-in-cond
Open

antonwolfy wants to merge 3 commits into
masterfrom
support-nuc-in-cond

Conversation

@antonwolfy

Copy link
Copy Markdown
Contributor

This PR adds the nuclear norm ("nuc") to the set of norms accepted by dpnp.linalg.cond, aligning its supported p values with dpnp.linalg.norm and with NumPy.

For "nuc" the condition number is computed through the existing inverse-based branch as norm(x, "nuc") * norm(inv(x), "nuc"), i.e. the product of the sums of the singular values of x and inv(x). This path was already functional (dpnp.linalg.norm supports "nuc" for matrices), so no change to the computation itself is required — the result matches NumPy for non-singular, batched, complex, boolean, empty, and strided inputs.

Consistent with the other inverse-based norms (1, -1, inf, -inf, "fro"), dpnp.linalg.cond raises LinAlgError on singular input when p="nuc", because dpnp.linalg.inv raises on singular matrices rather than filling the result with inf the way NumPy does.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

Add the nuclear norm ('nuc') to the set of norms accepted by
dpnp.linalg.cond. The condition number for 'nuc' is already computed
correctly through the inverse-based branch (norm(x, 'nuc') *
norm(inv(x), 'nuc')); this change documents it as a supported value of
p and adds test coverage.

Unlike NumPy, dpnp.linalg.inv raises LinAlgError on singular input, so
cond with 'nuc' raises on singular matrices consistently with the other
inverse-based norms (1, -1, inf, -inf, 'fro'); no special NaN handling
is required.

Update the docstring (parameter set, norm table, Notes, example), add
'nuc' to the TestCond norm list and to the cond sycl-queue/usm-type
propagation tests, and add a CHANGELOG entry.
@antonwolfy antonwolfy added this to the 0.21.0 release milestone Oct 2, 2026
@antonwolfy antonwolfy self-assigned this Oct 2, 2026
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/3084/index.html

@coveralls

coveralls commented Oct 2, 2026 •

Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.622%. remained the same — support-nuc-in-cond into master

@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev11=np2py314h8d9cdd5_17 ran successfully.
Passed: 1376
Failed: 0
Skipped: 6

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants