<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
gelq2.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_GELQ2_HH
13#define TLAPACK_GELQ2_HH
14
18
19namespace tlapack {
20
31template <class T, TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR vector_t>
32constexpr WorkInfo gelq2_worksize(const matrix_t& A, const vector_t& tauw)
33{
34 using idx_t = size_type<matrix_t>;
36
37 // constants
38 const idx_t m = nrows(A);
39
40 if (m > 1) {
41 auto&& C = rows(A, range{1, m});
43 tauw[0], C);
44 }
45 return WorkInfo(0);
46}
47
56template <TLAPACK_SMATRIX matrix_t,
57 TLAPACK_VECTOR vector_t,
58 TLAPACK_WORKSPACE work_t>
60{
61 using idx_t = size_type<matrix_t>;
63
64 // constants
65 const idx_t m = nrows(A);
66 const idx_t n = ncols(A);
67 const idx_t k = min(m, n);
68
69 // check arguments
70 tlapack_check_false((idx_t)size(tauw) < k);
71
72 for (idx_t j = 0; j < k; ++j) {
73 // Define w := A(j,j:n)
74 auto w = slice(A, j, range(j, n));
75
76 // Generate elementary reflector H(j) to annihilate A(j,j+1:n)
78
79 // If either condition is satisfied, Q11 will not be empty
80 if (j < k - 1 || k < m) {
81 // Apply H(j) to A(j+1:m,j:n) from the right
82 auto Q11 = slice(A, range(j + 1, m), range(j, n));
84 work);
85 }
86 }
87
88 return 0;
89}
90
125template <TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR vector_t>
127{
128 using T = type_t<matrix_t>;
129
130 // functor
132
133 // Allocates workspace
135 std::vector<T> work_;
136 auto work = new_matrix(work_, workinfo.m, workinfo.n);
137
138 return gelq2_work(A, tauw, work);
139}
140} // namespace tlapack
141
142#endif // TLAPACK_GELQ2_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
#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
#define TLAPACK_VECTOR
Macro for tlapack::concepts::Vector compatible with C++17.
Definition concepts.hpp:906
int gelq2(matrix_t &A, vector_t &tauw)
Computes an LQ factorization of a complex m-by-n matrix A using an unblocked algorithm.
Definition gelq2.hpp:126
void larfg(storage_t storeMode, type_t< vector_t > &alpha, vector_t &x, type_t< vector_t > &tau)
Generates a elementary Householder reflection.
Definition larfg.hpp:73
void larf_work(side_t side, storage_t storeMode, vector_t const &x, const tau_t &tau, vectorC0_t &C0, matrixC1_t &C1, work_t &work)
Applies an elementary reflector defined by tau and v to a m-by-n matrix C decomposed into C0 and C1....
Definition larf.hpp:48
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
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
constexpr WorkInfo gelq2_worksize(const matrix_t &A, const vector_t &tauw)
Worspace query of gelq2()
Definition gelq2.hpp:32
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