Skip to content

Commit a33a710

Browse files
authored
Add specification for computing the qr factorization (#126)
* Add qr specification * Update copy * Add dtype requirements * Update copy * Move API to submodule
1 parent e32a6a8 commit a33a710

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

Diff for: spec/API_specification/linear_algebra_functions.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,36 @@ Computes the (Moore-Penrose) pseudo-inverse of a matrix (or a stack of square ma
313313

314314
- an array containing the pseudo-inverses. The returned array must have a floating-point data type determined by {ref}`type-promotion` and must have shape `(..., N, M)` (i.e., must have the same shape as `x`, except the innermost two dimensions must be transposed).
315315

316-
(function-qr)=
317-
### qr()
316+
(function-linalg-qr)=
317+
### linalg.qr(x, /, *, mode='reduced')
318318

319-
TODO
319+
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).
320+
321+
#### Parameters
322+
323+
- **x**: _<array>_
324+
325+
- input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices. Should have a floating-point data type.
326+
327+
- **mode**: _str_
328+
329+
- factorization mode. Should be one of the following modes:
330+
331+
- `'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)`.
332+
- `'complete'`: compute `q` and `r` with dimensions `(..., M, M)` and `(..., M, N)`, respectively.
333+
334+
Default: `'reduced'`.
335+
336+
#### Returns
337+
338+
- **out**: _Tuple\[ <array>, <array> ]_
339+
340+
- a namedtuple `(q, r)` whose
341+
342+
- 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`.
343+
- 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`.
344+
345+
Each returned array must have a floating-point data type determined by {ref}`type-promotion`.
320346

321347
(function-linalg-slogdet)=
322348
### linalg.slogdet(x, /)

0 commit comments

Comments
 (0)