Skip to content

Commit e0c0c87

Browse files
authored
Add specification for computing the number of non-zero singular values of a matrix (linalg: matrix_rank) (#128)
* Add matrix_rank specification * Update copy * Reorder sentences * Fix missing clause * Rename keyword argument * Update copy * Update dtype requirements * Update wording * Move API to submodule
1 parent 7557e69 commit e0c0c87

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

spec/API_specification/linear_algebra_functions.md

+19-3
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,26 @@ The `matmul` function must implement the same semantics as the built-in `@` oper
278278

279279
TODO
280280

281-
(function-matrix_rank)=
282-
### matrix_rank()
281+
(function-linalg-matrix_rank)=
282+
### linalg.matrix_rank(x, /, *, rtol=None)
283283

284-
TODO
284+
Computes the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices).
285+
286+
#### Parameters
287+
288+
- **x**: _<array>_
289+
290+
- input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Should have a floating-point data type.
291+
292+
- **rtol**: _Optional\[ Union\[ float, <array> ] ]_
293+
294+
- relative tolerance for small singular values. Singular values less than or equal to `rtol * largest_singular_value` are set to zero. If a `float`, the value is equivalent to a zero-dimensional array having a floating-point data type determined by {ref}`type-promotion` (as applied to `x`) and must be broadcast against each matrix. If an `array`, must have a floating-point data type and must be compatible with `shape(x)[:-2]` (see {ref}`broadcasting`). If `None`, the default value is `max(M, N) * eps`, where `eps` must be the machine epsilon associated with the floating-point data type determined by {ref}`type-promotion` (as applied to `x`). Default: `None`.
295+
296+
#### Returns
297+
298+
- **out**: _<array>_
299+
300+
- an array containing the ranks. The returned array must have a floating-point data type determined by {ref}`type-promotion` and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`).
285301

286302
(function-norm)=
287303
### norm(x, /, *, axis=None, keepdims=False, ord=None)

0 commit comments

Comments
 (0)