12#ifndef TLAPACK_GEQLF_HH
13#define TLAPACK_GEQLF_HH
40template <
class T, TLAPACK_SMATRIX A_t, TLAPACK_SVECTOR tau_t>
45 using idx_t = size_type<A_t>;
46 using range = pair<idx_t, idx_t>;
47 using work_t = matrix_type<A_t, tau_t>;
50 const idx_t m = nrows(A);
51 const idx_t n = ncols(A);
52 const idx_t k = min(m, n);
53 const idx_t nb = min((idx_t)opts.nb, k);
55 auto&& A11 = cols(A, range(0, nb));
56 auto&& tauw1 = slice(tau, range(0, nb));
57 WorkInfo workinfo = geql2_worksize<T>(A11, tauw1);
60 auto&& TT1 = slice(A, range(0, nb), range(0, nb));
61 auto&& A12 = slice(A, range(0, m), range(nb, n));
62 workinfo.minMax(larfb_worksize<T>(LEFT_SIDE, CONJ_TRANS, BACKWARD,
63 COLUMNWISE_STORAGE, A11, TT1, A12));
64 if constexpr (is_same_v<T, type_t<work_t>>)
65 workinfo += WorkInfo(nb, nb);
79template <TLAPACK_SMATRIX A_t, TLAPACK_SVECTOR tau_t, TLAPACK_WORKSPACE work_t>
82 using idx_t = size_type<A_t>;
83 using range = pair<idx_t, idx_t>;
86 const idx_t m = nrows(A);
87 const idx_t n = ncols(A);
88 const idx_t k = min(m, n);
89 const idx_t nb = min((idx_t)opts.nb, k);
95 auto [TT, work2] = (n > nb) ? reshape(work, nb, nb) : reshape(work, 0, 0);
98 for (idx_t j2 = 0; j2 < k; j2 += nb) {
100 idx_t ib = min(nb, k - j2);
103 auto A11 = slice(A, range(0, m - (n - j)), range(j - ib, j));
104 auto tauw1 = slice(tau, range(k - (n - j) - ib, k - (n - j)));
110 auto TT1 = slice(TT, range(0, ib), range(0, ib));
111 larft(BACKWARD, COLUMNWISE_STORAGE, A11, tauw1, TT1);
114 auto A12 = slice(A, range(0, m - (n - j)), range(0, j - ib));
115 larfb_work(LEFT_SIDE, CONJ_TRANS, BACKWARD, COLUMNWISE_STORAGE, A11,
156template <TLAPACK_SMATRIX A_t, TLAPACK_SVECTOR tau_t>
159 using work_t = matrix_type<A_t, tau_t>;
160 using T = type_t<work_t>;
161 Create<work_t> new_matrix;
164 WorkInfo workinfo = geqlf_worksize<T>(A, tau, opts);
165 std::vector<T> work_;
166 auto work = new_matrix(work_, workinfo.m, workinfo.n);
int geqlf(A_t &A, tau_t &tau, const GeqlfOpts &opts={})
Computes an RQ factorization of an m-by-n matrix A using a blocked algorithm.
Definition geqlf.hpp:157
int larfb_work(side_t side, trans_t trans, direction_t direction, storage_t storeMode, const matrixV_t &V, const matrixT_t &Tmatrix, matrixC_t &C, work_t &work)
Applies a block reflector or its conjugate transpose to a m-by-n matrix C, from either the left or ...
Definition larfb.hpp:111
int larft(direction_t direction, storage_t storeMode, const matrixV_t &V, const vector_t &tau, matrixT_t &T)
Forms the triangular factor T of a block reflector H of order n, which is defined as a product of k e...
Definition larft.hpp:92
int geql2_work(matrix_t &A, vector_t &tau, work_t &work)
Computes a QL factorization of a matrix A. Workspace is provided as an argument.
Definition geql2.hpp:60
int geqlf_work(A_t &A, tau_t &tau, work_t &work, const GeqlfOpts &opts={})
Computes an RQ factorization of an m-by-n matrix A using a blocked algorithm. Workspace is provided...
Definition geqlf.hpp:80
#define tlapack_check(cond)
Throw an error if cond is false.
Definition exceptionHandling.hpp:98
constexpr WorkInfo geqlf_worksize(const A_t &A, const tau_t &tau, const GeqlfOpts &opts={})
Worspace query of geqlf()
Definition geqlf.hpp:41
Applies a Householder block reflector to a matrix.
Forms the triangular factor T of a block reflector.
typename traits::real_type_traits< Types..., int >::type real_type
The common real type of the list of types.
Definition scalar_type_traits.hpp:113
Options struct for gelqf.
Definition geqlf.hpp:24
size_t nb
Block size.
Definition geqlf.hpp:25
Output information in the workspace query.
Definition workspace.hpp:16