<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
gelqt.hpp
Go to the documentation of this file.
1
5//
6// Copyright (c) 2021-2023, University of Colorado Denver. All rights reserved.
7//
8// This file is part of <T>LAPACK.
9// <T>LAPACK is free software: you can redistribute it and/or modify it under
10// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
11
12#ifndef TLAPACK_GELQT_HH
13#define TLAPACK_GELQT_HH
14
19
20namespace tlapack {
21
32template <class T, TLAPACK_SMATRIX matrix_t>
33constexpr WorkInfo gelqt_worksize(const matrix_t& A, const matrix_t& TT)
34{
35 using idx_t = size_type<matrix_t>;
37
38 // constants
39 const idx_t m = nrows(A);
40 const idx_t n = ncols(A);
41 const idx_t k = min(m, n);
42 const idx_t nb = min((idx_t)ncols(TT), k);
43
44 auto&& TT1 = slice(TT, range(0, nb), range(0, nb));
45 auto&& A11 = rows(A, range(0, nb));
46 auto&& tauw1 = diag(TT1);
47
49}
50
59template <TLAPACK_SMATRIX matrix_t, TLAPACK_WORKSPACE work_t>
61{
62 using idx_t = size_type<matrix_t>;
64
65 // constants
66 const idx_t m = nrows(A);
67 const idx_t n = ncols(A);
68 const idx_t k = min(m, n);
69 const idx_t nb = ncols(TT);
70
71 // check arguments
72 tlapack_check_false(nrows(TT) < m || ncols(TT) < nb);
73
74 for (idx_t j = 0; j < k; j += nb) {
75 // Use blocked code initially
76 idx_t ib = min(nb, k - j);
77
78 // Compute the LQ factorization of the current block A(j:j+ib-1,j:n)
79 auto TT1 = slice(TT, range(j, j + ib), range(0, ib));
80 auto A11 = slice(A, range(j, j + ib), range(j, n));
81 auto tauw1 = diag(TT1);
82
84
85 // Form the triangular factor of the block reflector H = H(j) H(j+1)
86 // . . . H(j+ib-1)
88
89 if (j + ib < k) {
90 // Apply H to A(j+ib:m,j:n) from the right
91 auto A12 = slice(A, range(j + ib, m), range(j, n));
92 auto work1 = slice(TT, range(j + ib, m), range(0, ib));
94 A12, work1);
95 }
96 }
97
98 return 0;
99}
100
145template <TLAPACK_SMATRIX matrix_t>
147{
148 using T = type_t<matrix_t>;
149
150 // functors
152
153 // Allocates workspace
155 std::vector<T> work_;
156 auto work = new_matrix(work_, workinfo.m, workinfo.n);
157
158 return gelqt_work(A, TT, work);
159}
160} // namespace tlapack
161#endif // TLAPACK_GELQT_HH
constexpr internal::RightSide RIGHT_SIDE
right side
Definition types.hpp:291
constexpr internal::RowwiseStorage ROWWISE_STORAGE
Rowwise storage.
Definition types.hpp:411
constexpr internal::Forward FORWARD
Forward direction.
Definition types.hpp:376
constexpr internal::NoTranspose NO_TRANS
no transpose
Definition types.hpp:255
constexpr auto diag(T &A, int diagIdx=0) noexcept
Get the Diagonal of an Eigen Matrix.
Definition eigen.hpp:576
int gelqt(matrix_t &A, matrix_t &TT)
Computes an LQ factorization of a complex m-by-n matrix A using a blocked algorithm.
Definition gelqt.hpp:146
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 gelq2_work(matrix_t &A, vector_t &tauw, work_t &work)
Computes an LQ factorization of a complex m-by-n matrix A using an unblocked algorithm....
Definition gelq2.hpp:59
int gelqt_work(matrix_t &A, matrix_t &TT, work_t &work)
Computes an LQ factorization of a complex m-by-n matrix A using a blocked algorithm....
Definition gelqt.hpp:60
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
constexpr WorkInfo gelqt_worksize(const matrix_t &A, const matrix_t &TT)
Worspace query of gelqt()
Definition gelqt.hpp:33
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
Output information in the workspace query.
Definition workspace.hpp:16