<T>LAPACK 0.1.2
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
trge_ung2r.hpp
Go to the documentation of this file.
1
4// Copyright (c) 2025, University of Colorado Denver. All rights reserved.
5//
6// This file is part of <T>LAPACK.
7// <T>LAPACK is free software: you can redistribute it and/or modify it under
8// the terms of the BSD 3-Clause license. See the accompanying LICENSE file.
9
10#ifndef TLAPACK_TRGE_UNG2R_HH
11#define TLAPACK_TRGE_UNG2R_HH
12
14
15using namespace tlapack;
16
17template <TLAPACK_SMATRIX matrix_t, TLAPACK_VECTOR vector_t>
18void trge_ung2r(matrix_t& W, vector_t& tau)
19{
20 using idx_t = size_type<matrix_t>;
22 using T = type_t<matrix_t>;
23 using real_t = real_type<T>;
24
25 // Functors for creating new matrices
27
28 idx_t n = tau.size();
29 idx_t m = nrows(W) - n;
30 idx_t k = ncols(W);
31
32 auto Winit0 = slice(W, range{0, n}, range{n, k});
33 laset(GENERAL, real_t(0.0), real_t(0.0), Winit0);
34
35 auto Winit1 = slice(W, range{n, m + n}, range{n, k});
36 laset(GENERAL, real_t(0.0), real_t(1.0), Winit1);
37
38 auto v = slice(W, range{n, m + n}, n - 1);
39 auto W0 = slice(W, n - 1, range{n, k});
40 auto W1 = slice(W, range{n, m + n}, range{n, k});
41
42 std::vector<T> work_;
43 auto work = new_matrix(work_, m + n, 1);
44
45 if (k > n)
47
48 for (idx_t j = 0; j < n - 1; j++)
49 W(j, n - 1) = 0.;
50 scal(-tau[n - 1], v);
51 W(n - 1, n - 1) = T(1) - tau[n - 1];
52
53 for (idx_t i = n - 1; i-- > 0;) {
54 auto v = slice(W, range{n, m + n}, i);
55 auto W0 = slice(W, i, range{i + 1, k});
56 auto W1 = slice(W, range{n, m + n}, range{i + 1, k});
57
59
60 for (idx_t j = 0; j < i; j++)
61 W(j, i) = 0.;
62 scal(-tau[i], v);
63 W(i, i) = T(1) - tau[i];
64 }
65}
66
67#endif // TLAPACK_TRGE_UNG2R_HH
void laset(uplo_t uplo, const type_t< matrix_t > &alpha, const type_t< matrix_t > &beta, matrix_t &A)
Initializes a matrix to diagonal and off-diagonal values.
Definition laset.hpp:38
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
void scal(const alpha_t &alpha, vector_t &x)
Scale vector by constant, .
Definition scal.hpp:30
Sort the numbers in D in increasing order (if ID = 'I') or in decreasing order (if ID = 'D' ).
Definition arrayTraits.hpp:15
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
constexpr internal::GeneralAccess GENERAL
General access.
Definition types.hpp:180
constexpr internal::ColumnwiseStorage COLUMNWISE_STORAGE
Columnwise storage.
Definition types.hpp:414
constexpr internal::LeftSide LEFT_SIDE
left side
Definition types.hpp:294