Direct Tall-and-Skinny QR algorithm As presented in: A. Benson, D. Gleich, and J. Demmel. Direct QR factorizations for tall-and-skinny matrices in MapReduce architectures. IEEE International Conference on Big Data, 2013. https://arxiv.org/abs/1301.1071
(data, compute_svd=False, _max_vchunk_size=None)
| 58 | |
| 59 | |
| 60 | def tsqr(data, compute_svd=False, _max_vchunk_size=None): |
| 61 | """Direct Tall-and-Skinny QR algorithm |
| 62 | |
| 63 | As presented in: |
| 64 | |
| 65 | A. Benson, D. Gleich, and J. Demmel. |
| 66 | Direct QR factorizations for tall-and-skinny matrices in |
| 67 | MapReduce architectures. |
| 68 | IEEE International Conference on Big Data, 2013. |
| 69 | https://arxiv.org/abs/1301.1071 |
| 70 | |
| 71 | This algorithm is used to compute both the QR decomposition and the |
| 72 | Singular Value Decomposition. It requires that the input array have a |
| 73 | single column of blocks, each of which fit in memory. |
| 74 | |
| 75 | Parameters |
| 76 | ---------- |
| 77 | data: Array |
| 78 | compute_svd: bool |
| 79 | Whether to compute the SVD rather than the QR decomposition |
| 80 | _max_vchunk_size: Integer |
| 81 | Used internally in recursion to set the maximum row dimension |
| 82 | of chunks in subsequent recursive calls. |
| 83 | |
| 84 | Notes |
| 85 | ----- |
| 86 | With ``k`` blocks of size ``(m, n)``, this algorithm has memory use that |
| 87 | scales as ``k * n * n``. |
| 88 | |
| 89 | The implementation here is the recursive variant due to the ultimate |
| 90 | need for one "single core" QR decomposition. In the non-recursive version |
| 91 | of the algorithm, given ``k`` blocks, after ``k`` ``m * n`` QR |
| 92 | decompositions, there will be a "single core" QR decomposition that will |
| 93 | have to work with a ``(k * n, n)`` matrix. |
| 94 | |
| 95 | Here, recursion is applied as necessary to ensure that ``k * n`` is not |
| 96 | larger than ``m`` (if ``m / n >= 2``). In particular, this is done |
| 97 | to ensure that single core computations do not have to work on blocks |
| 98 | larger than ``(m, n)``. |
| 99 | |
| 100 | Where blocks are irregular, the above logic is applied with the "height" of |
| 101 | the "tallest" block used in place of ``m``. |
| 102 | |
| 103 | Consider use of the ``rechunk`` method to control this behavior. |
| 104 | Taller blocks will reduce overall memory use (assuming that many of them |
| 105 | still fit in memory at once). |
| 106 | |
| 107 | See Also |
| 108 | -------- |
| 109 | dask.array.linalg.qr |
| 110 | Powered by this algorithm |
| 111 | dask.array.linalg.svd |
| 112 | Powered by this algorithm |
| 113 | dask.array.linalg.sfqr |
| 114 | Variant for short-and-fat arrays |
| 115 | """ |
| 116 | nr, nc = len(data.chunks[0]), len(data.chunks[1]) |
| 117 | cr_max, cc = max(data.chunks[0]), data.chunks[1][0] |