ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
linear_gmres.h
Go to the documentation of this file.
1#ifndef HSOLVER_LINEAR_GMRES_H
2#define HSOLVER_LINEAR_GMRES_H
5
6namespace hsolver
7{
9template <typename T, typename Device>
11{
12 private:
13 using Wide = std::complex<double>;
14 using Real = typename GetTypeReal<T>::type;
15 const double tolerance_;
20 std::vector<std::vector<Wide>> h_;
21 std::vector<std::vector<Wide>> g_;
22 std::vector<std::vector<Wide>> sine_;
23 std::vector<std::vector<double>> cosine_;
24 std::vector<int> order_;
25 std::vector<int> swaps_;
26 int ld_ = 0;
27 int dim_ = 0;
28 int bands_ = 0;
29 int stride_ = 0;
30 int active_ = 0;
31
32 T* vector(int slot);
33 T* residual();
34 T* solution();
35 T* basis(int index);
36 T* direction(int index);
37 T* image(int index);
38 bool start_cycle(const std::vector<double>& threshold, std::vector<T>* coefficients);
39 void orthogonalize(int j, T* next, std::vector<T>* coefficients);
40 bool update_qr(int b, int j, double norm);
41 bool back_substitute(int b, int j, std::vector<Wide>* weights);
42 void update_solution(int j,
43 const std::vector<int>& done,
44 const std::vector<std::vector<Wide>>& weights,
45 bool reconstruct,
46 std::vector<T>* coefficients);
47 void retire(int band);
48 void apply_swaps(int last);
49 bool cycle(const LinearOperator<T, Device>& op,
50 const LinearOperator<T, Device>& preconditioner,
51 const std::vector<double>& threshold,
52 bool reconstruct,
53 int max_iter,
54 LinearSolveResult* result);
55
56 public:
57 LinearGMRES(double tolerance, int restart, int max_iter, const diag_comm_info& comm);
60 const LinearOperator<T, Device>& preconditioner,
61 int ld,
62 int nvec,
63 int dim,
64 T* x,
65 const T* b,
66 const T* initial_residual,
67 bool force_check,
68 int max_iter,
69 bool reconstruct);
70};
71} // namespace hsolver
72#endif
A multi-dimensional array of elements of a single data type.
Definition tensor.h:32
Collective block algebra; only small coefficients cross the device boundary.
Definition linear_algebra.h:53
ct::Tensor krylov_
Definition linear_gmres.h:19
int bands_
Definition linear_gmres.h:28
bool cycle(const LinearOperator< T, Device > &op, const LinearOperator< T, Device > &preconditioner, const std::vector< double > &threshold, bool reconstruct, int max_iter, LinearSolveResult *result)
Definition linear_gmres.cpp:228
T * solution()
Definition linear_gmres.cpp:65
int active_
Definition linear_gmres.h:30
T * basis(int index)
Definition linear_gmres.cpp:71
T * vector(int slot)
Definition linear_gmres.cpp:21
std::complex< double > Wide
Definition linear_gmres.h:13
void update_solution(int j, const std::vector< int > &done, const std::vector< std::vector< Wide > > &weights, bool reconstruct, std::vector< T > *coefficients)
Definition linear_gmres.cpp:159
void orthogonalize(int j, T *next, std::vector< T > *coefficients)
Definition linear_gmres.cpp:91
bool update_qr(int b, int j, double norm)
Definition linear_gmres.cpp:112
std::vector< int > swaps_
Definition linear_gmres.h:25
int dim_
Definition linear_gmres.h:27
bool back_substitute(int b, int j, std::vector< Wide > *weights)
Definition linear_gmres.cpp:139
void retire(int band)
Definition linear_gmres.cpp:27
typename GetTypeReal< T >::type Real
Definition linear_gmres.h:14
T * direction(int index)
Definition linear_gmres.cpp:77
LinearGMRES(double tolerance, int restart, int max_iter, const diag_comm_info &comm)
Definition linear_gmres.cpp:9
bool start_cycle(const std::vector< double > &threshold, std::vector< T > *coefficients)
Definition linear_gmres.cpp:192
int ld_
Definition linear_gmres.h:26
std::vector< std::vector< Wide > > sine_
Definition linear_gmres.h:22
std::vector< int > order_
Definition linear_gmres.h:24
const double tolerance_
Definition linear_gmres.h:15
T * residual()
Definition linear_gmres.cpp:59
std::vector< std::vector< Wide > > h_
Definition linear_gmres.h:20
LinearAlgebra< T, Device > algebra_
Definition linear_gmres.h:18
int stride_
Definition linear_gmres.h:29
T * image(int index)
Definition linear_gmres.cpp:84
LinearSolveResult solve(const LinearOperator< T, Device > &op, const LinearOperator< T, Device > &preconditioner, int ld, int nvec, int dim, T *x, const T *b, const T *initial_residual, bool force_check, int max_iter, bool reconstruct)
Use the per-call budget and reconstruction policy; force_check requests an independent final applicat...
Definition linear_gmres.cpp:292
std::vector< std::vector< Wide > > g_
Definition linear_gmres.h:21
int restart_
Definition linear_gmres.h:16
void apply_swaps(int last)
Definition linear_gmres.cpp:44
std::vector< std::vector< double > > cosine_
Definition linear_gmres.h:23
LinearWorkspace< T, Device > work_
Definition linear_gmres.h:17
Device-resident block operator for independent right-hand sides.
Definition linear_operator.h:31
Reusable device arrays and collective block algebra for linear solvers.
Definition linear_workspace.h:34
#define T
Definition exp.cpp:237
Definition dense_eigensolver.cpp:23
#define threshold
Definition sph_bessel_rec_test.cpp:4
T type
Definition macros.h:8
Convergence result, operator work, and independent or reconstructed residual provenance.
Definition linear_solver_types.h:20
Definition diag_comm_info.h:12
double norm(const Vec3 &v)
Definition test_partition.cpp:25