PARALUTION  1.0.0
PARALUTION
cg_hn.hpp
Go to the documentation of this file.
1 // *************************************************************************
2 //
3 // This code is developed and maintained by NTU.
4 // The SIRA eigenvalue solver (files src/solvers/eigenvalue/amppe_sira.hpp
5 // src/solvers/eigenvalue/amppe_sira.cpp src/solvers/deflation/cg_hn.hpp
6 // src/solvers/deflation/cg_hn.cpp) are released under GNU LESSER GENERAL
7 // PUBLIC LICENSE (LGPL v3)
8 //
9 // Copyright (C) 2014 Weichung Wang (NTU)
10 // National Taiwan University, National Taiwan
11 //
12 // This program is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as
14 // published by the Free Software Foundation, either version 3 of the
15 // License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this program.
24 // If not, see <http://www.gnu.org/licenses/>.
25 //
26 // *************************************************************************
27 
28 #ifndef PARALUTION_EIGENVALUE_CG_HN_HPP_
29 #define PARALUTION_EIGENVALUE_CG_HN_HPP_
30 
31 #include "../solver.hpp"
32 #include "../krylov/cg.hpp"
33 #include <assert.h>
34 #include <math.h>
35 #include <fstream>
36 #include <vector>
37 
38 namespace paralution {
39 template <class OperatorType, class VectorType, typename ValueType>
40 class CG_HN : public paralution::CG<OperatorType, VectorType, ValueType> {
41 
42 public:
43 
44  CG_HN();
45  virtual ~CG_HN();
46  virtual void Print(void) const;
47  virtual void Build(void);
48  virtual void Clear(void);
49 
50  virtual void MoveToAcceleratorLocalData_(void);
51  virtual void MoveToHostLocalData_(void);
52 
53  virtual void Solve (const VectorType &rhs, VectorType *x, VectorType &u_k);
54 
55  virtual void SetIta (const ValueType a) {this->Ita_ = a; return;};
56  virtual void SetTol_out (const ValueType a) {this->Tol_out_ = a; return;};
57  virtual void SetNorm_r_out(const ValueType a) {this->norm_r_out_ = a; return;};
58  virtual void SetAlpha (const ValueType a) {this->alpha_set_ = a; return;};
59  virtual void SetTau_1 (const ValueType a) {this->Tau_1_ = a; return;};
60  virtual void SetTau_2 (const ValueType a) {this->Tau_2_ = a; return;};
61  virtual void SetTau_3 (const ValueType a) {this->Tau_3_ = a; return;};
62 
63 protected:
64  virtual void SolveNonPrecond(const VectorType &rhs, VectorType *x, VectorType &u_k);
65  virtual void SolvePrecond (const VectorType &rhs, VectorType *x, VectorType &u_k);
66 
67  virtual void PrintStart_(void) const;
68  virtual void PrintEnd_(void) const;
69 
70 private:
71 
72  virtual void GetBeta (VectorType *x, const VectorType &u_k);
73  virtual void Get_r_eig (void);
74  virtual bool JudgeCaseB(void);
75  virtual bool JudgeCaseC(void);
76  virtual bool Check_HN (ValueType res, VectorType *x, VectorType &u_k);
79  VectorType r_, z_;
80  VectorType p_, q_;
81  VectorType u_A_, x_A_;
83  ValueType g_k_[2];
85 
86 };
87 
88 }
89 
90 #endif // PARALUTION_EIGENVALUE_CG_HN_HPP_
91 
92 
ValueType alpha_set_
Definition: cg_hn.hpp:82
virtual void Clear(void)
Clear (free all local data) the solver.
Definition: cg_hn.cpp:498
virtual void SetIta(const ValueType a)
Definition: cg_hn.hpp:55
VectorType p_
Definition: cg_hn.hpp:80
virtual void Solve(const VectorType &rhs, VectorType *x, VectorType &u_k)
Definition: cg_hn.cpp:574
bool IsFirst_
Definition: cg_hn.hpp:77
virtual bool Check_HN(ValueType res, VectorType *x, VectorType &u_k)
Definition: cg_hn.cpp:124
ValueType Tol_out_
Definition: cg_hn.hpp:84
VectorType q_
Definition: cg_hn.hpp:80
virtual bool JudgeCaseC(void)
Definition: cg_hn.cpp:232
ValueType norm_r_out_
Definition: cg_hn.hpp:84
virtual void Print(void) const
Print information about the solver.
Definition: cg_hn.cpp:77
VectorType r_
Definition: cg_hn.hpp:79
ValueType g_k_[2]
Definition: cg_hn.hpp:83
bool CaseB_
Definition: cg_hn.hpp:77
virtual void Build(void)
Build the solver (data allocation, structure computation, numerical computation)
Definition: cg_hn.cpp:441
Definition: cg.hpp:11
virtual void SolvePrecond(const VectorType &rhs, VectorType *x, VectorType &u_k)
Definition: cg_hn.cpp:345
ValueType Tau_3_
Definition: cg_hn.hpp:84
virtual void PrintStart_(void) const
Print starting msg of the solver.
Definition: cg_hn.cpp:93
virtual void SetTau_1(const ValueType a)
Definition: cg_hn.hpp:59
virtual void MoveToHostLocalData_(void)
Move all local data to the host.
Definition: cg_hn.cpp:526
virtual void SetNorm_r_out(const ValueType a)
Definition: cg_hn.hpp:57
VectorType u_A_
Definition: cg_hn.hpp:81
ValueType beta_set_
Definition: cg_hn.hpp:82
ValueType Tau_2_
Definition: cg_hn.hpp:84
bool CaseC_
Definition: cg_hn.hpp:77
Definition: cg_hn.hpp:40
ValueType Ita_
Definition: cg_hn.hpp:84
ValueType Tau_1_
Definition: cg_hn.hpp:84
virtual void SetTau_2(const ValueType a)
Definition: cg_hn.hpp:60
virtual void SetTol_out(const ValueType a)
Definition: cg_hn.hpp:56
virtual void MoveToAcceleratorLocalData_(void)
Move all local data to the accelerator.
Definition: cg_hn.cpp:550
virtual bool JudgeCaseB(void)
Definition: cg_hn.cpp:212
CG_HN()
Definition: cg_hn.cpp:40
virtual void SolveNonPrecond(const VectorType &rhs, VectorType *x, VectorType &u_k)
Definition: cg_hn.cpp:251
int GetBetaTime_
Definition: cg_hn.hpp:78
Definition: backend_manager.cpp:43
virtual void Get_r_eig(void)
Definition: cg_hn.cpp:195
VectorType x_A_
Definition: cg_hn.hpp:81
VectorType z_
Definition: cg_hn.hpp:79
const IndexType const IndexType const IndexType const ValueType const ValueType const ValueType * x
Definition: cuda_kernels_coo.hpp:91
virtual ~CG_HN()
Definition: cg_hn.cpp:67
virtual void SetAlpha(const ValueType a)
Definition: cg_hn.hpp:58
bool UsingHN_
Definition: cg_hn.hpp:77
virtual void SetTau_3(const ValueType a)
Definition: cg_hn.hpp:61
ValueType s_set_
Definition: cg_hn.hpp:82
virtual void GetBeta(VectorType *x, const VectorType &u_k)
Definition: cg_hn.cpp:171
ValueType ResAtFirst_
Definition: cg_hn.hpp:84
ValueType r_eig_
Definition: cg_hn.hpp:82
virtual void PrintEnd_(void) const
Print ending msg of the solver.
Definition: cg_hn.cpp:109