| 65 | |
| 66 | template<typename T> |
| 67 | void qr(Array<T> &q, Array<T> &r, Array<T> &t, const Array<T> &in) { |
| 68 | dim4 iDims = in.dims(); |
| 69 | int M = iDims[0]; |
| 70 | int N = iDims[1]; |
| 71 | |
| 72 | const dim4 NullShape(0, 0, 0, 0); |
| 73 | |
| 74 | dim4 endPadding(M - iDims[0], max(M, N) - iDims[1], 0, 0); |
| 75 | q = (endPadding == NullShape |
| 76 | ? copyArray(in) |
| 77 | : padArrayBorders(in, NullShape, endPadding, AF_PAD_ZERO)); |
| 78 | q.resetDims(iDims); |
| 79 | t = qr_inplace(q); |
| 80 | |
| 81 | // SPLIT into q and r |
| 82 | dim4 rdims(M, N); |
| 83 | r = createEmptyArray<T>(rdims); |
| 84 | |
| 85 | triangle<T>(r, q, true, false); |
| 86 | |
| 87 | auto func = [=](Param<T> q, Param<T> t, int M, int N) { |
| 88 | gqr_func<T>()(AF_LAPACK_COL_MAJOR, M, M, min(M, N), q.get(), |
| 89 | q.strides(1), t.get()); |
| 90 | }; |
| 91 | q.resetDims(dim4(M, M)); |
| 92 | getQueue().enqueue(func, q, t, M, N); |
| 93 | } |
| 94 | |
| 95 | template<typename T> |
| 96 | Array<T> qr_inplace(Array<T> &in) { |
nothing calls this directly
no test coverage detected