<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
move_bulge.hpp
Go to the documentation of this file.
1
3//
4// Copyright (c) 2021-2023, 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_MOVE_BULGE_HH
11#define TLAPACK_MOVE_BULGE_HH
12
16
17namespace tlapack {
18
36template <TLAPACK_SMATRIX matrix_t, TLAPACK_CVECTOR vector_t>
38 vector_t& v,
41{
42 using T = type_t<matrix_t>;
43 using real_t = real_type<T>;
44
45 using idx_t = size_type<matrix_t>;
47 const real_t zero(0);
48 const real_t eps = ulp<real_t>();
49
51
52 // Perform delayed update of row below the bulge
53 // Assumes the first two elements of the row are zero
54 scalar_type<type_t<vector_t>, T> refsum = v[0] * v[2] * H(3, 2);
55 H(3, 0) = -refsum;
56 H(3, 1) = -refsum * conj(v[1]);
57 H(3, 2) = H(3, 2) - refsum * conj(v[2]);
58
59 // Generate reflector to move bulge down
60 T tau, beta;
61 v[0] = H(1, 0);
62 v[1] = H(2, 0);
63 v[2] = H(3, 0);
65 beta = v[0];
66 v[0] = tau;
67
68 // Check for bulge collapse
69 if (H(3, 0) != zero or H(3, 1) != zero or H(3, 2) != zero) {
70 // The bulge hasn't collapsed, typical case
71 H(1, 0) = beta;
72 H(2, 0) = zero;
73 H(3, 0) = zero;
74 }
75 else {
76 // The bulge has collapsed, attempt to reintroduce using
77 // 2-small-subdiagonals trick
78 T vt_[3];
79 auto vt = new_3_vector(vt_);
80 auto H2 = slice(H, range{1, 4}, range{1, 4});
83 vt[0] = tau;
84
85 refsum = conj(vt[0]) * H(1, 0) + conj(vt[1]) * H(2, 0);
86 if (abs1(H(2, 0) - refsum * vt[1]) + abs1(refsum * vt[2]) >
87 eps * (abs1(H(0, 0)) + abs1(H(1, 1)) + abs1(H(2, 2)))) {
88 // Starting a new bulge here would create non-negligible fill. Use
89 // the old one.
90 H(1, 0) = beta;
91 H(2, 0) = zero;
92 H(3, 0) = zero;
93 }
94 else {
95 // Fill-in is negligible, use the new reflector.
96 H(1, 0) = H(1, 0) - refsum;
97 H(2, 0) = zero;
98 H(3, 0) = zero;
99 v[0] = vt[0];
100 v[1] = vt[1];
101 v[2] = vt[2];
102 }
103 }
104}
105
106} // namespace tlapack
107
108#endif // TLAPACK_MOVE_BULGE_HH
constexpr internal::Forward FORWARD
Forward direction.
Definition types.hpp:376
constexpr internal::ColumnwiseStorage COLUMNWISE_STORAGE
Columnwise storage.
Definition types.hpp:409
constexpr T conj(const T &x) noexcept
Extends std::conj() to real datatypes.
Definition utils.hpp:100
constexpr real_type< T > abs1(const T &x)
1-norm absolute value, |Re(x)| + |Im(x)|
Definition utils.hpp:133
void move_bulge(matrix_t &H, vector_t &v, complex_type< type_t< matrix_t > > s1, complex_type< type_t< matrix_t > > s2)
Given a 4-by-3 matrix H and small order reflector v, move_bulge applies the delayed right update to t...
Definition move_bulge.hpp:37
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
int lahqr_shiftcolumn(const matrix_t &H, vector_t &v, complex_type< type_t< matrix_t > > s1, complex_type< type_t< matrix_t > > s2)
Given a 2-by-2 or 3-by-3 matrix H, lahqr_shiftcolumn calculates a multiple of the product: (H - s1*I)...
Definition lahqr_shiftcolumn.hpp:41
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
typename traits::complex_type_traits< Types..., int >::type complex_type
The common complex type of the list of types.
Definition scalar_type_traits.hpp:188