<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
gehd2.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_GEHD2_HH
13#define TLAPACK_GEHD2_HH
14
18
19namespace tlapack {
20
37template <class T, TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR vector_t>
40 const matrix_t& A,
41 const vector_t& tau)
42{
43 using idx_t = size_type<matrix_t>;
45
46 // constants
47 const idx_t n = ncols(A);
48
50 if (ilo + 1 < ihi && n > 0) {
51 auto&& v = slice(A, range{ilo + 1, ihi}, ilo);
52
53 auto&& C0 = slice(A, range{0, ihi}, range{ilo + 1, ihi});
55 tau[0], C0);
56
57 auto&& C1 = slice(A, range{ilo + 1, ihi}, range{ilo + 1, n});
59 v, tau[0], C1));
60 }
61
62 return workinfo;
63}
64
73template <TLAPACK_SMATRIX matrix_t,
74 TLAPACK_VECTOR vector_t,
75 TLAPACK_WORKSPACE work_t>
78 matrix_t& A,
80 work_t& work)
81{
82 using idx_t = size_type<matrix_t>;
84
85 // constants
86 const idx_t n = ncols(A);
87
88 // check arguments
89 tlapack_check_false(ncols(A) != nrows(A));
90 tlapack_check_false((idx_t)size(tau) < n - 1);
91
92 // quick return
93 if (n <= 0) return 0;
94
95 for (idx_t i = ilo; i < ihi - 1; ++i) {
96 // Define v := A[i+1:ihi,i]
97 auto v = slice(A, range{i + 1, ihi}, i);
98
99 // Generate the (i+1)-th elementary Householder reflection on v
101
102 // Apply Householder reflection from the right to A[0:ihi,i+1:ihi]
103 auto C0 = slice(A, range{0, ihi}, range{i + 1, ihi});
105
106 // Apply Householder reflection from the left to A[i+1:ihi,i+1:n-1]
107 auto C1 = slice(A, range{i + 1, ihi}, range{i + 1, n});
109 work);
110 }
111
112 return 0;
113}
114
152template <TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR vector_t>
155 matrix_t& A,
156 vector_t& tau)
157{
158 using idx_t = size_type<matrix_t>;
159 using T = type_t<matrix_t>;
160
161 // functor
163
164 // constants
165 const idx_t n = ncols(A);
166
167 // check arguments
168 tlapack_check_false(ncols(A) != nrows(A));
169 tlapack_check_false((idx_t)size(tau) < n - 1);
170
171 // quick return
172 if (n <= 0) return 0;
173
174 // Allocates workspace
176 std::vector<T> work_;
177 auto work = new_matrix(work_, workinfo.m, workinfo.n);
178
179 return gehd2_work(ilo, ihi, A, tau, work);
180}
181
182} // namespace tlapack
183
184#endif // TLAPACK_GEHD2_HH
constexpr internal::RightSide RIGHT_SIDE
right side
Definition types.hpp:291
constexpr internal::Forward FORWARD
Forward direction.
Definition types.hpp:376
constexpr internal::ColumnwiseStorage COLUMNWISE_STORAGE
Columnwise storage.
Definition types.hpp:409
constexpr internal::LeftSide LEFT_SIDE
left side
Definition types.hpp:289
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
#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 gehd2(size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, vector_t &tau)
Reduces a general square matrix to upper Hessenberg form.
Definition gehd2.hpp:153
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 gehd2_work(size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, vector_t &tau, work_t &work)
Reduces a general square matrix to upper Hessenberg form. Workspace is provided as an argument.
Definition gehd2.hpp:76
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
constexpr WorkInfo gehd2_worksize(size_type< matrix_t > ilo, size_type< matrix_t > ihi, const matrix_t &A, const vector_t &tau)
Worspace query of gehd2()
Definition gehd2.hpp:38
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