Skip to content

Add specification for computing the number of non-zero singular values of a matrix (linalg: matrix_rank) #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 12, 2021

Conversation

kgryte
Copy link
Contributor

@kgryte kgryte commented Feb 16, 2021

This PR

  • specifies the interface for computing the rank (i.e., number of non-zero singular values) of a matrix.
  • is derived from comparing signatures across array libraries.

Notes

  • CuPy and Torch (torch.matrix_rank) do not support providing stacks of matrices. Torch latest master does. This proposal follows NumPy and other linalg APIs in supporting stacks.

  • Dask does not have a matrix_rank API.

  • NumPy, MXNet, Torch (latest master) support a hermitian keyword argument to indicate a potential optimization. This keyword argument is not widely supported and is not included in this proposal.

  • Torch (latest master), CuPy, and possibly TF only support specifying tol as a float. This PR follows NumPy and other API proposals (e.g., pinv and lstsq) in allowing tol to be specified as either a float or an array of floats. Providing an array allows specifying one or more tolerances. This PR specifies tolerance as rtol to more explicitly indicate relative tolerance and to distinguish from atol (absolute tolerance).

  • TF supports a validate_args keyword argument. TF is alone in doing so, and such a keyword argument is not included in this proposal.

@kgryte
Copy link
Contributor Author

kgryte commented Mar 4, 2021

Renamed tol to rtol to more explicitly indicate relative tolerance and pave the way for future specification evolution (e.g., atol).

@rgommers rgommers added the API extension Adds new functions or objects to the API. label Mar 20, 2021
@rgommers rgommers force-pushed the main branch 3 times, most recently from 0607525 to 138e963 Compare April 19, 2021 20:25
@kgryte
Copy link
Contributor Author

kgryte commented May 12, 2021

This PR has been open for some time without further comment and has been discussed/approved during meetings. Will merge, and we can submit follow-up PRs should any issues/concerns arise.

@kgryte kgryte merged commit e0c0c87 into main May 12, 2021
@kgryte kgryte deleted the matrix_rank branch May 12, 2021 05:10
@kgryte
Copy link
Contributor Author

kgryte commented May 12, 2021

For reference, inclusion of this API was discussed here.

rgommers added a commit to rgommers/array-api that referenced this pull request Nov 16, 2022
This was a simple mistake, not discussed in the review for the PR
that added `matrix_rank` (data-apisgh-128).

Closes data-apisgh-469
kgryte pushed a commit that referenced this pull request Nov 16, 2022
This was a simple mistake, not discussed in the review for the PR
that added `matrix_rank` (gh-128).

Closes gh-469
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API extension Adds new functions or objects to the API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants