From 66b1404677e25375fb2da27113ad7d11049010f9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 15 Feb 2021 21:01:20 -0800 Subject: [PATCH 1/9] Add matrix_rank specification --- .../linear_algebra_functions.md | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 209a2f787..f5e77b9a2 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -150,9 +150,25 @@ TODO TODO (function-matrix_rank)= -### matrix_rank() +### matrix_rank(x, /, *, tol=None) -TODO +Computes the rank (i.e., number of non-zero singular values) of a matrix (or stack of matrices). + +#### Parameters + +- **x**: _<array>_ + + - input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Must have a data type of either `float32` or `float64`. + +- **tol**: _Optional\[ Union\[ float, <array> ] ]_ + + - cutoffs for small singular values. Singular values less than or equal to `tol * largest_singular_value` are set to zero. If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. 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 floating-point epsilon associated with the data type of `x`. Default: `None`. + +#### Returns + +- **out**: _<array>_ + + - an array containing the ranks. The returned array must have the same data type and must have shape `(...)` (i.e., must have the same shape as `shape(x)[:-2]`). (function-norm)= ### norm(x, /, *, axis=None, keepdims=False, ord=None) From e39b42865892267b3378de9152c8a293b6117683 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 15 Feb 2021 21:03:24 -0800 Subject: [PATCH 2/9] Update copy --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index f5e77b9a2..bba6f59b2 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -168,7 +168,7 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or sta - **out**: _<array>_ - - an array containing the ranks. The returned array must have the same data type and must have shape `(...)` (i.e., must have the same shape as `shape(x)[:-2]`). + - an array containing the ranks. The returned array must have the same data type and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). (function-norm)= ### norm(x, /, *, axis=None, keepdims=False, ord=None) From 57da6e805f30a216fa8ee6a6605a927ba7c6f5e2 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 15 Feb 2021 21:14:35 -0800 Subject: [PATCH 3/9] Reorder sentences --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index bba6f59b2..815663434 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -162,7 +162,7 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or sta - **tol**: _Optional\[ Union\[ float, <array> ] ]_ - - cutoffs for small singular values. Singular values less than or equal to `tol * largest_singular_value` are set to zero. If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. 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 floating-point epsilon associated with the data type of `x`. Default: `None`. + - cutoffs for small singular values. Singular values less than or equal to `tol * largest_singular_value` are set to zero. Must be compatible with `shape(x)[:-2]` (see {ref}`broadcasting`). If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. If `None`, the default value is `max(M, N) * eps`, where `eps` must be the floating-point epsilon associated with the data type of `x`. Default: `None`. #### Returns From 5abd01fd16fe302e265b13cc60ea073a40f8b711 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 15 Feb 2021 22:04:29 -0800 Subject: [PATCH 4/9] Fix missing clause --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 815663434..4b9a25fb6 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -168,7 +168,7 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or sta - **out**: _<array>_ - - an array containing the ranks. The returned array must have the same data type and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). + - an array containing the ranks. The returned array must have the same data type as `x` and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). (function-norm)= ### norm(x, /, *, axis=None, keepdims=False, ord=None) From 284611e7d2e958de00aeae6aae661dc280b50851 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Thu, 4 Mar 2021 01:18:14 -0800 Subject: [PATCH 5/9] Rename keyword argument --- spec/API_specification/linear_algebra_functions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 4b9a25fb6..7bb45ab68 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -150,7 +150,7 @@ TODO TODO (function-matrix_rank)= -### matrix_rank(x, /, *, tol=None) +### matrix_rank(x, /, *, rtol=None) Computes the rank (i.e., number of non-zero singular values) of a matrix (or stack of matrices). @@ -160,9 +160,9 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or sta - input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Must have a data type of either `float32` or `float64`. -- **tol**: _Optional\[ Union\[ float, <array> ] ]_ +- **rtol**: _Optional\[ Union\[ float, <array> ] ]_ - - cutoffs for small singular values. Singular values less than or equal to `tol * largest_singular_value` are set to zero. Must be compatible with `shape(x)[:-2]` (see {ref}`broadcasting`). If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. If `None`, the default value is `max(M, N) * eps`, where `eps` must be the floating-point epsilon associated with the data type of `x`. Default: `None`. + - relative tolerance for small singular values. Singular values less than or equal to `rtol * largest_singular_value` are set to zero. Must be compatible with `shape(x)[:-2]` (see {ref}`broadcasting`). If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. If `None`, the default value is `max(M, N) * eps`, where `eps` must be the machine epsilon associated with the data type of `x`. Default: `None`. #### Returns From d19799c9832cdf1dd4c6f3f786aad14795ef8747 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 15:24:10 -0700 Subject: [PATCH 6/9] Update copy --- spec/API_specification/linear_algebra_functions.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 7bb45ab68..53e27560a 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -152,7 +152,7 @@ TODO (function-matrix_rank)= ### matrix_rank(x, /, *, rtol=None) -Computes the rank (i.e., number of non-zero singular values) of a matrix (or stack of matrices). +Computes the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices). #### Parameters From d482dc7ef8f5cdf99a0a335d5047f70dcc317e40 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 17:31:50 -0700 Subject: [PATCH 7/9] Update dtype requirements --- spec/API_specification/linear_algebra_functions.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 53e27560a..45424639d 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -158,17 +158,17 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or a s - **x**: _<array>_ - - input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Must have a data type of either `float32` or `float64`. + - input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Should have a floating-point data type. - **rtol**: _Optional\[ Union\[ float, <array> ] ]_ - - relative tolerance for small singular values. Singular values less than or equal to `rtol * largest_singular_value` are set to zero. Must be compatible with `shape(x)[:-2]` (see {ref}`broadcasting`). If a `float`, the value is equivalent to a zero-dimensional array having the same data type as `x` and is broadcast against each matrix. If `None`, the default value is `max(M, N) * eps`, where `eps` must be the machine epsilon associated with the data type of `x`. Default: `None`. + - 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` rules (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` rules (as applied to `x`). Default: `None`. #### Returns - **out**: _<array>_ - - an array containing the ranks. The returned array must have the same data type as `x` and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). + - an array containing the ranks. The returned array must have a floating-point data type determined by {ref}`type-promotion` rules and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). (function-norm)= ### norm(x, /, *, axis=None, keepdims=False, ord=None) From a5d2c6188bbbd604b7ab9e95f7e84eef87fcb983 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 17:33:53 -0700 Subject: [PATCH 8/9] Update wording --- spec/API_specification/linear_algebra_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 45424639d..0765e30c4 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -162,13 +162,13 @@ Computes the rank (i.e., number of non-zero singular values) of a matrix (or a s - **rtol**: _Optional\[ Union\[ float, <array> ] ]_ - - 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` rules (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` rules (as applied to `x`). Default: `None`. + - 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`. #### Returns - **out**: _<array>_ - - an array containing the ranks. The returned array must have a floating-point data type determined by {ref}`type-promotion` rules and must have shape `(...)` (i.e., must have a shape equal to `shape(x)[:-2]`). + - 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]`). (function-norm)= ### norm(x, /, *, axis=None, keepdims=False, ord=None) From e77fc96c0446965b0e8e8699e27732dafd923e13 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 26 Apr 2021 02:28:51 -0700 Subject: [PATCH 9/9] Move API to submodule --- spec/API_specification/linear_algebra_functions.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 0765e30c4..3b99eb3f2 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -149,8 +149,8 @@ TODO TODO -(function-matrix_rank)= -### matrix_rank(x, /, *, rtol=None) +(function-linalg-matrix_rank)= +### linalg.matrix_rank(x, /, *, rtol=None) Computes the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices).