Compute the qr factorization of a matrix. Parameters ---------- a : Array Returns ------- q: Array, orthonormal r: Array, upper-triangular Examples -------- >>> q, r = da.linalg.qr(x) # doctest: +SKIP See Also -------- numpy.linalg.qr:
(a)
| 833 | |
| 834 | |
| 835 | def qr(a): |
| 836 | """ |
| 837 | Compute the qr factorization of a matrix. |
| 838 | |
| 839 | Parameters |
| 840 | ---------- |
| 841 | a : Array |
| 842 | |
| 843 | Returns |
| 844 | ------- |
| 845 | q: Array, orthonormal |
| 846 | r: Array, upper-triangular |
| 847 | |
| 848 | Examples |
| 849 | -------- |
| 850 | >>> q, r = da.linalg.qr(x) # doctest: +SKIP |
| 851 | |
| 852 | See Also |
| 853 | -------- |
| 854 | numpy.linalg.qr: Equivalent NumPy Operation |
| 855 | dask.array.linalg.tsqr: Implementation for tall-and-skinny arrays |
| 856 | dask.array.linalg.sfqr: Implementation for short-and-fat arrays |
| 857 | """ |
| 858 | |
| 859 | if len(a.chunks[1]) == 1 and len(a.chunks[0]) > 1: |
| 860 | return tsqr(a) |
| 861 | elif len(a.chunks[0]) == 1: |
| 862 | return sfqr(a) |
| 863 | else: |
| 864 | raise NotImplementedError( |
| 865 | "qr currently supports only tall-and-skinny (single column chunk/block; see tsqr)\n" |
| 866 | "and short-and-fat (single row chunk/block; see sfqr) matrices\n\n" |
| 867 | "Consider use of the rechunk method. For example,\n\n" |
| 868 | "x.rechunk({0: -1, 1: 'auto'}) or x.rechunk({0: 'auto', 1: -1})\n\n" |
| 869 | "which rechunk one shorter axis to a single chunk, while allowing\n" |
| 870 | "the other axis to automatically grow/shrink appropriately." |
| 871 | ) |
| 872 | |
| 873 | |
| 874 | def svd(a, coerce_signs=True, full_matrices=False): |