12#ifndef TLAPACK_MULTISHIFT_QR_HH
13#define TLAPACK_MULTISHIFT_QR_HH
25 enable_if_t<is_complex<type_t<vector_t>>,
int> = 0>
26constexpr WorkInfo multishift_qr_worksize_sweep(
bool want_t,
28 size_type<matrix_t> ilo,
29 size_type<matrix_t> ihi,
33 const FrancisOpts& opts = {})
35 using idx_t = size_type<matrix_t>;
36 using range = pair<idx_t, idx_t>;
38 const idx_t n = ncols(A);
39 const idx_t nh = ihi - ilo;
40 const idx_t nsr = opts.nshift_recommender(n, nh);
41 auto&& shifts = slice(w, range{0, nsr});
43 return multishift_QR_sweep_worksize<T>(want_t, want_z, ilo, ihi, A, shifts,
71 enable_if_t<is_complex<type_t<vector_t>>,
int>>
83 const idx_t n = ncols(
A);
90 const idx_t
nw_max = (n - 3) / 3;
93 want_t,
want_z,
ilo,
ihi,
nw_max,
A,
w,
Z, 0, 0,
opts);
113 enable_if_t<is_complex<type_t<vector_t>>,
int>>
136 const idx_t n = ncols(
A);
142 const idx_t nmin =
opts.nmin;
145 const idx_t
nsr =
opts.nshift_recommender(n,
nh);
148 const idx_t
nwr =
opts.deflation_window_recommender(n,
nh);
149 const idx_t
nw_max = (n - 3) / 3;
151 const idx_t nibble =
opts.nibble;
155 int n_shifts_total = 0;
165 if (
nh <= 0)
return 0;
176 const idx_t
itmax = 30 * std::max<idx_t>(10,
nh);
210 for (idx_t i =
istop - 1; i >
ilo; --i) {
211 if (
A(i, i - 1) ==
zero) {
268 if (i > 1)
ss +=
abs1(
A(i - 1, i - 2));
307 for (idx_t i =
i_shifts; i <
k - 1; ++i) {
334 if (
ns % 2 == 1)
ns =
ns - 1;
353 n_sweep = n_sweep + 1;
354 n_shifts_total = n_shifts_total +
ns;
360 opts.n_shifts_total = n_shifts_total;
361 opts.n_sweep = n_sweep;
380 enable_if_t<is_complex<type_t<vector_t>>,
int> = 0>
383 size_type<matrix_t> ilo,
384 size_type<matrix_t> ihi,
390 FrancisOpts opts = {};
446 enable_if_t<is_complex<type_t<vector_t>>,
int> = 0>
462 const idx_t n = ncols(
A);
468 const idx_t nmin =
opts.nmin;
471 if (
nh <= 0)
return 0;
482 std::vector<TA>
work_;
500 enable_if_t<is_complex<type_t<vector_t>>,
int> = 0>
503 size_type<matrix_t> ilo,
504 size_type<matrix_t> ihi,
509 FrancisOpts opts = {};
510 return multishift_qr(want_t, want_z, ilo, ihi, A, w, Z, opts);
constexpr real_type< T > real(const T &x) noexcept
Extends std::real() to real datatypes.
Definition utils.hpp:71
constexpr real_type< T > abs1(const T &x)
1-norm absolute value, |Re(x)| + |Im(x)|
Definition utils.hpp:133
constexpr real_type< T > imag(const T &x) noexcept
Extends std::imag() to real datatypes.
Definition utils.hpp:86
#define TLAPACK_SVECTOR
Macro for tlapack::concepts::SliceableVector compatible with C++17.
Definition concepts.hpp:909
#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
#define TLAPACK_MATRIX
Macro for tlapack::concepts::Matrix compatible with C++17.
Definition concepts.hpp:896
int multishift_qr(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, vector_t &w, matrix_t &Z, FrancisOpts &opts)
multishift_qr computes the eigenvalues and optionally the Schur factorization of an upper Hessenberg ...
Definition multishift_qr.hpp:447
void lahqr_eig22(T a00, T a01, T a10, T a11, complex_type< T > &s1, complex_type< T > &s2)
Computes the eigenvalues of a 2x2 matrix A.
Definition lahqr_eig22.hpp:34
int lahqr(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, vector_t &w, matrix_t &Z)
lahqr computes the eigenvalues and optionally the Schur factorization of an upper Hessenberg matrix,...
Definition lahqr.hpp:73
void aggressive_early_deflation_work(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, size_type< matrix_t > nw, matrix_t &A, vector_t &s, matrix_t &Z, size_type< matrix_t > &ns, size_type< matrix_t > &nd, work_t &work, FrancisOpts &opts)
aggressive_early_deflation accepts as input an upper Hessenberg matrix H and performs an orthogonal s...
Definition aggressive_early_deflation.hpp:168
int multishift_qr_work(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, vector_t &w, matrix_t &Z, work_t &work, FrancisOpts &opts)
multishift_qr computes the eigenvalues and optionally the Schur factorization of an upper Hessenberg ...
Definition multishift_qr.hpp:114
void multishift_QR_sweep_work(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, matrix_t &A, const vector_t &s, matrix_t &Z, work_t &work)
multishift_QR_sweep performs a single small-bulge multi-shift QR sweep. Workspace is provided as an...
Definition multishift_qr_sweep.hpp:77
#define tlapack_check_false(cond)
Throw an error if cond is true.
Definition exceptionHandling.hpp:113
WorkInfo multishift_qr_worksize(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, const matrix_t &A, const vector_t &w, const matrix_t &Z, const FrancisOpts &opts={})
Worspace query of multishift_qr()
Definition multishift_qr.hpp:72
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
Options struct for multishift_qr().
Definition FrancisOpts.hpp:23
Output information in the workspace query.
Definition workspace.hpp:16