From c68f421b046cf155a42b7c92984324fae08d0500 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 15 Feb 2021 02:28:45 -0800 Subject: [PATCH 1/5] Add qr specification --- .../linear_algebra_functions.md | 28 +++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 209a2f787..0e869e9c2 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -260,9 +260,33 @@ Computes the outer product of two vectors `x1` and `x2`. TODO (function-qr)= -### qr() +### qr(x, /, *, mode='reduced') -TODO +Computes the qr factorization of a matrix (or stack of matrices), where `q` is an orthonormal matrix (or stack of matrices) and `r` is an upper-triangular 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`. + +- **mode**: _str_ + + - factorization mode. Should be one of the following modes: + + - `'reduced'`: compute only the leading `K` columns of `q`, such that `q` and `r` have dimensions `(..., M, K)` and `(..., K, N)`, respectively, and where `K = min(M, N)`. + - `'complete'`: compute `q` and `r` with dimensions `(..., M, M)` and `(..., M, N)`, respectively. + + Default: `'reduced'`. + +#### Returns + +- **out**: _Tuple\[ <array>, ... ]_ + + - a namedtuple `(q, r)` whose + + - first element must be an array whose shape depends on the value of `mode` and contain orthonormal matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., M, K)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. + - second element must be an array whose shape depends on the value of `mode` and contain upper-triangular matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., K, N)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. (function-slogdet)= ### slogdet() From 492ef82c2de831cf43d64ea3742a244aa8fc3d03 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 15:23:07 -0700 Subject: [PATCH 2/5] 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 0e869e9c2..5dc597668 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -262,7 +262,7 @@ TODO (function-qr)= ### qr(x, /, *, mode='reduced') -Computes the qr factorization of a matrix (or stack of matrices), where `q` is an orthonormal matrix (or stack of matrices) and `r` is an upper-triangular matrix (or stack of matrices). +Computes the qr factorization of a matrix (or a stack of matrices), where `q` is an orthonormal matrix (or a stack of matrices) and `r` is an upper-triangular matrix (or a stack of matrices). #### Parameters From 89c47536d453920843900c17ce1fc2c0383035b9 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 17:19:16 -0700 Subject: [PATCH 3/5] Add dtype requirements --- spec/API_specification/linear_algebra_functions.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/API_specification/linear_algebra_functions.md b/spec/API_specification/linear_algebra_functions.md index 5dc597668..3a62648d3 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -268,7 +268,7 @@ Computes the qr factorization of a matrix (or a stack of matrices), where `q` is - **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. - **mode**: _str_ @@ -281,13 +281,15 @@ Computes the qr factorization of a matrix (or a stack of matrices), where `q` is #### Returns -- **out**: _Tuple\[ <array>, ... ]_ +- **out**: _Tuple\[ <array>, <array> ]_ - a namedtuple `(q, r)` whose - first element must be an array whose shape depends on the value of `mode` and contain orthonormal matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., M, K)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. - second element must be an array whose shape depends on the value of `mode` and contain upper-triangular matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., K, N)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. + Each returned array must have a floating-point data type determined by {ref}`type-promotion` rules. + (function-slogdet)= ### slogdet() From da0c933b7cefc6b7e5657f4760f17fd48009b2d3 Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Wed, 24 Mar 2021 17:41:32 -0700 Subject: [PATCH 4/5] 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 3a62648d3..26c5a7b1b 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -288,7 +288,7 @@ Computes the qr factorization of a matrix (or a stack of matrices), where `q` is - first element must be an array whose shape depends on the value of `mode` and contain orthonormal matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., M, K)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. - second element must be an array whose shape depends on the value of `mode` and contain upper-triangular matrices. If `mode` is `'complete'`, the array must have shape `(..., M, M)`. If `mode` is `'reduced'`, the array must have shape `(..., K, N)`, where `K = min(M, N)`. The first `x.ndim-2` dimensions must have the same size as those of the input `x`. - Each returned array must have a floating-point data type determined by {ref}`type-promotion` rules. + Each returned array must have a floating-point data type determined by {ref}`type-promotion`. (function-slogdet)= ### slogdet() From eeab850f79a139e9366829c4df9cdae1ae01373b Mon Sep 17 00:00:00 2001 From: Athan Reines Date: Mon, 26 Apr 2021 02:37:02 -0700 Subject: [PATCH 5/5] 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 26c5a7b1b..109d23666 100644 --- a/spec/API_specification/linear_algebra_functions.md +++ b/spec/API_specification/linear_algebra_functions.md @@ -259,8 +259,8 @@ Computes the outer product of two vectors `x1` and `x2`. TODO -(function-qr)= -### qr(x, /, *, mode='reduced') +(function-linalg-qr)= +### linalg.qr(x, /, *, mode='reduced') Computes the qr factorization of a matrix (or a stack of matrices), where `q` is an orthonormal matrix (or a stack of matrices) and `r` is an upper-triangular matrix (or a stack of matrices).