<T>LAPACK 0.1.1
C++ Template Linear Algebra PACKage
Loading...
Searching...
No Matches
FrancisOpts.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_FRANCIS_OPTS_HH
11#define TLAPACK_FRANCIS_OPTS_HH
12
13#include <cmath>
14#include <functional>
15
17
18namespace tlapack {
19
26 std::function<size_t(size_t, size_t)> nshift_recommender =
27 [](size_t n, size_t nh) -> size_t {
28 if (n < 30) return 2;
29 if (n < 60) return 4;
30 if (n < 150) return 10;
31 if (n < 590) return size_t(n / std::log2(n));
32 if (n < 3000) return 64;
33 if (n < 6000) return 128;
34 return 256;
35 };
36
39 std::function<size_t(size_t, size_t)> deflation_window_recommender =
40 [](size_t n, size_t nh) -> size_t {
41 if (n < 30) return 2;
42 if (n < 60) return 4;
43 if (n < 150) return 10;
44 if (n < 590) return size_t(n / std::log2(n));
45 if (n < 3000) return 96;
46 if (n < 6000) return 192;
47 return 384;
48 };
49
50 // On exit of the routine. Stores the number of times AED and sweep were
51 // called And the total number of shifts used.
52 int n_aed = 0;
53 int n_sweep = 0;
55
57 size_t nmin = 75;
59 size_t nibble = 14;
60};
61
62// Forward declarations:
63
64template <class T,
69 bool want_z,
72 const matrix_t& A,
73 const vector_t& w,
74 const matrix_t& Z,
75 const FrancisOpts& opts = {});
76
77template <TLAPACK_SMATRIX matrix_t,
78 TLAPACK_SVECTOR vector_t,
79 TLAPACK_WORKSPACE work_t,
80 enable_if_t<is_complex<type_t<vector_t> >, int> = 0>
81int multishift_qr_work(bool want_t,
82 bool want_z,
83 size_type<matrix_t> ilo,
84 size_type<matrix_t> ihi,
85 matrix_t& A,
86 vector_t& w,
87 matrix_t& Z,
88 work_t& work,
89 FrancisOpts& opts);
90
91template <class T,
92 TLAPACK_SMATRIX matrix_t,
93 TLAPACK_SVECTOR vector_t,
94 enable_if_t<is_complex<type_t<vector_t> >, int> = 0>
95WorkInfo aggressive_early_deflation_worksize(bool want_t,
96 bool want_z,
97 size_type<matrix_t> ilo,
98 size_type<matrix_t> ihi,
99 size_type<matrix_t> nw,
100 const matrix_t& A,
101 const vector_t& s,
102 const matrix_t& Z,
103 const size_type<matrix_t>& ns,
104 const size_type<matrix_t>& nd,
105 const FrancisOpts& opts = {});
106
107template <TLAPACK_SMATRIX matrix_t,
108 TLAPACK_SVECTOR vector_t,
109 TLAPACK_WORKSPACE work_t,
110 enable_if_t<is_complex<type_t<vector_t> >, int> = 0>
111void aggressive_early_deflation_work(bool want_t,
112 bool want_z,
113 size_type<matrix_t> ilo,
114 size_type<matrix_t> ihi,
115 size_type<matrix_t> nw,
116 matrix_t& A,
117 vector_t& s,
118 matrix_t& Z,
119 size_type<matrix_t>& ns,
120 size_type<matrix_t>& nd,
121 work_t& work,
122 FrancisOpts& opts);
123
124} // namespace tlapack
125
126#endif // TLAPACK_FRANCIS_OPTS_HH
#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
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
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
WorkInfo aggressive_early_deflation_worksize(bool want_t, bool want_z, size_type< matrix_t > ilo, size_type< matrix_t > ihi, size_type< matrix_t > nw, const matrix_t &A, const vector_t &s, const matrix_t &Z, const size_type< matrix_t > &ns, const size_type< matrix_t > &nd, const FrancisOpts &opts)
Worspace query of aggressive_early_deflation().
Definition aggressive_early_deflation.hpp:119
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
int n_sweep
number of sweeps used
Definition FrancisOpts.hpp:53
std::function< size_t(size_t, size_t)> nshift_recommender
Function that returns the number of shifts to use for a given matrix size.
Definition FrancisOpts.hpp:26
std::function< size_t(size_t, size_t)> deflation_window_recommender
Function that returns the number of shifts to use for a given matrix size.
Definition FrancisOpts.hpp:39
size_t nmin
Threshold to switch between blocked and unblocked code.
Definition FrancisOpts.hpp:57
int n_shifts_total
total number of shifts used
Definition FrancisOpts.hpp:54
int n_aed
number of times AED was called
Definition FrancisOpts.hpp:52
size_t nibble
Threshold of percent of AED window that must converge to skip a sweep.
Definition FrancisOpts.hpp:59
Output information in the workspace query.
Definition workspace.hpp:16