12#ifndef TLAPACK_UNGBR_HH
13#define TLAPACK_UNGBR_HH
47template <
class T, TLAPACK_SMATRIX matrix_t, TLAPACK_SVECTOR vector_t>
53 using idx_t = size_type<matrix_t>;
54 using range = pair<idx_t, idx_t>;
57 const idx_t m = nrows(A);
60 return ungq_worksize<T>(FORWARD, COLUMNWISE_STORAGE, A, tau,
64 auto&& A2 = slice(A, range{0, m - 1}, range{0, m - 1});
65 auto&& tau2 = slice(tau, range{0, m - 1});
66 return ungq_worksize<T>(FORWARD, COLUMNWISE_STORAGE, A2, tau2,
91template <
class T, TLAPACK_SMATRIX matrix_t, TLAPACK_SVECTOR vector_t>
97 using idx_t = size_type<matrix_t>;
98 using range = pair<idx_t, idx_t>;
101 const idx_t n = ncols(A);
104 auto&& A2 = slice(A, range{0, n - 1}, range{0, n - 1});
105 auto&& tau2 = slice(tau, range{0, n - 1});
106 return ungq_worksize<T>(FORWARD, ROWWISE_STORAGE, A2, tau2,
110 return ungq_worksize<T>(FORWARD, ROWWISE_STORAGE, A, tau,
132 using T = type_t<matrix_t>;
133 using real_t = real_type<T>;
134 using idx_t = size_type<matrix_t>;
135 using range = pair<idx_t, idx_t>;
138 const real_t zero(0);
140 const idx_t m = nrows(A);
144 ungq_work(FORWARD, COLUMNWISE_STORAGE, A, tau, work, UngqOpts{opts.nb});
150 for (idx_t j = m - 1; j > 0; --j) {
152 for (idx_t i = j + 1; i < m; ++i)
153 A(i, j) = A(i, j - 1);
156 for (idx_t i = 1; i < m; ++i)
160 auto A2 = slice(A, range{1, m}, range{1, m});
161 auto tau2 = slice(tau, range{0, m - 1});
162 ungq_work(FORWARD, COLUMNWISE_STORAGE, A2, tau2, work,
200template <TLAPACK_SMATRIX matrix_t, TLAPACK_SVECTOR vector_t>
206 using work_t = matrix_type<matrix_t, vector_t>;
207 using T = type_t<work_t>;
210 Create<work_t> new_matrix;
213 WorkInfo workinfo = ungbr_q_worksize<T>(k, A, tau, opts);
214 std::vector<T> work_;
215 auto work = new_matrix(work_, workinfo.m, workinfo.n);
237 using T = type_t<matrix_t>;
238 using real_t = real_type<T>;
239 using idx_t = size_type<matrix_t>;
240 using range = pair<idx_t, idx_t>;
243 const real_t zero(0);
245 const idx_t n = ncols(A);
253 ungq_work(FORWARD, ROWWISE_STORAGE, A, tau, work, UngqOpts{opts.nb});
260 for (idx_t i = 1; i < n; ++i) {
263 for (idx_t j = 1; j < n; ++j) {
264 for (idx_t i = j - 1; i > 0; --i) {
265 A(i, j) = A(i - 1, j);
270 auto A2 = slice(A, range{1, n}, range{1, n});
271 auto tau2 = slice(tau, range{0, n - 1});
272 ungq_work(FORWARD, ROWWISE_STORAGE, A2, tau2, work,
310template <TLAPACK_SMATRIX matrix_t, TLAPACK_SVECTOR vector_t>
316 using work_t = matrix_type<matrix_t, vector_t>;
317 using T = type_t<work_t>;
320 Create<work_t> new_matrix;
323 WorkInfo workinfo = ungbr_p_worksize<T>(k, A, tau, opts);
324 std::vector<T> work_;
325 auto work = new_matrix(work_, workinfo.m, workinfo.n);
#define TLAPACK_SVECTOR
Macro for tlapack::concepts::SliceableVector compatible with C++17.
Definition concepts.hpp:909
#define TLAPACK_SMATRIX
Macro for tlapack::concepts::SliceableMatrix compatible with C++17.
Definition concepts.hpp:899
#define TLAPACK_WORKSPACE
Macro for tlapack::concepts::Workspace compatible with C++17.
Definition concepts.hpp:912
int ungbr_q(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, const UngbrOpts &opts={})
Generates the unitary matrix Q determined by gebrd when reducing a matrix A to bidiagonal form: A = Q...
Definition ungbr.hpp:201
int ungbr_p(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, const UngbrOpts &opts={})
Generates the unitary matrix P**H determined by gebrd when reducing a matrix A to bidiagonal form: A ...
Definition ungbr.hpp:311
int ungbr_p_work(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, work_t &work, const UngbrOpts &opts={})
Generates the unitary matrix P**H determined by gebrd when reducing a matrix A to bidiagonal form: A ...
Definition ungbr.hpp:231
int ungq_work(direction_t direction, storage_t storeMode, matrix_t &A, const vector_t &tau, work_t &work, const UngqOpts &opts={})
Generates a matrix Q that is the product of elementary reflectors. Workspace is provided as an argu...
Definition ungq.hpp:138
int ungbr_q_work(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, work_t &work, const UngbrOpts &opts={})
Generates the unitary matrix Q determined by gebrd when reducing a matrix A to bidiagonal form: A = Q...
Definition ungbr.hpp:126
constexpr WorkInfo ungbr_p_worksize(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, const UngbrOpts &opts={})
Worspace query of ungbr_p()
Definition ungbr.hpp:92
constexpr WorkInfo ungbr_q_worksize(const size_type< matrix_t > k, matrix_t &A, const vector_t &tau, const UngbrOpts &opts={})
Worspace query of ungbr_q()
Definition ungbr.hpp:48
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 ungbr.
Definition ungbr.hpp:23
size_t nb
Block size.
Definition ungbr.hpp:24
Output information in the workspace query.
Definition workspace.hpp:16