Bridge++  Ver. 2.0.2
asolver_CG.h
Go to the documentation of this file.
1 #ifndef ASOLVER_CG_H
2 #define ASOLVER_CG_H
3 
4 #include <cstdio>
5 #include <cstdlib>
6 #include <vector>
7 using std::vector;
8 #include <string>
9 using std::string;
10 
11 #include "lib/Fopr/afopr.h"
12 
13 #include "lib_alt/Solver/asolver.h"
14 
15 template<typename AFIELD>
16 class ASolver_CG : public ASolver<AFIELD>
17 {
18  public:
19  typedef typename AFIELD::real_t real_t;
21  static const std::string class_name;
23 
24  protected:
25 
27 
28  int m_Niter;
30 
32  int m_nconv;
33 
36 
38  ASolver_CG() { }
39 
42 
43  public:
46  : m_Niter(0), m_Stop_cond(0.0L)
47  {
48  m_fopr = fopr;
49  this->init();
50  }
51 
53  ~ASolver_CG() { this->tidyup(); }
54 
56  void set_parameters(const Parameters& params);
57 
59  void set_parameters(const int Niter, const real_t Stop_cond);
60 
62  void set_parameters(const int Niter, const real_t Stop_cond, const InitialGuess init_guess_mode);
63 
64  void set_init_mode(const InitialGuess init_guess)
65  {
66  m_initial_mode = init_guess;
67  }
68 
70  void solve(AFIELD& xq, const AFIELD& b, int& nconv, real_t& diff);
71 
73  AFopr<AFIELD> *get_fopr() { return m_fopr; }
74 
76  double flop_count();
77 
78 
79  protected:
80 
81  void init(void);
82 
83  void tidyup(void);
84 
85  void solve_CG_init(real_t& rrp, real_t& rr);
86 
87  void solve_CG_step(real_t& rrp, real_t& rr);
88 
89 
90 #ifdef USE_FACTORY
91  private:
92  static ASolver<AFIELD> *create_object_with_fopr(AFopr<AFIELD> *fopr)
93  { return new ASolver_CG<AFIELD>(fopr); }
94 
95  public:
96  static bool register_factory()
97  {
99  create_object_with_fopr);
100  return init;
101  }
102 #endif
103 };
104 
105 #endif // ASOLVER_CG_H
ASolver_CG::m_x
AFIELD m_x
working vectors.
Definition: asolver_CG.h:41
ASolver_CG::m_fopr
AFopr< AFIELD > * m_fopr
fermion operator.
Definition: asolver_CG.h:26
ASolver_CG::m_p
AFIELD m_p
Definition: asolver_CG.h:41
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
ASolver_CG::m_nconv
int m_nconv
to remember convergence iteration to provide flop count.
Definition: asolver_CG.h:32
ASolver_CG::solve_CG_step
void solve_CG_step(real_t &rrp, real_t &rr)
Definition: asolver_CG-tmpl.h:204
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver_CG::~ASolver_CG
~ASolver_CG()
destructor.
Definition: asolver_CG.h:53
ASolver_CG::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_CG-tmpl.h:35
ASolver_CG::solve_CG_init
void solve_CG_init(real_t &rrp, real_t &rr)
Definition: asolver_CG-tmpl.h:169
ASolver_CG
Definition: asolver_CG.h:16
ASolver_CG::m_s
AFIELD m_s
Definition: asolver_CG.h:41
ASolver_CG::solve
void solve(AFIELD &xq, const AFIELD &b, int &nconv, real_t &diff)
solver main.
Definition: asolver_CG-tmpl.h:110
ASolver_CG::m_Niter
int m_Niter
maximum iteration number.
Definition: asolver_CG.h:28
ASolver_CG::m_r
AFIELD m_r
Definition: asolver_CG.h:41
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
ASolver_CG::init
void init(void)
Definition: asolver_CG-tmpl.h:5
ASolver_CG::real_t
AFIELD::real_t real_t
Definition: asolver_CG.h:19
Field::real_t
double real_t
Definition: field.h:51
ASolver_CG::set_init_mode
void set_init_mode(const InitialGuess init_guess)
Definition: asolver_CG.h:64
ASolver_CG::get_fopr
AFopr< AFIELD > * get_fopr()
returns the pointer to the fermion operator.
Definition: asolver_CG.h:73
ASolver_CG::class_name
static const std::string class_name
Definition: asolver_CG.h:21
ASolver_CG::tidyup
void tidyup(void)
Definition: asolver_CG-tmpl.h:26
ASolver_CG::ASolver_CG
ASolver_CG()
calling constructor without fermion operator is forbidden.
Definition: asolver_CG.h:38
ASolver_CG::m_initial_mode
InitialGuess m_initial_mode
mode switch for initial guess
Definition: asolver_CG.h:35
ASolver_CG::ASolver_CG
ASolver_CG(AFopr< AFIELD > *fopr)
constructor.
Definition: asolver_CG.h:45
ASolver_CG::m_Stop_cond
real_t m_Stop_cond
stopping criterion (squared).
Definition: asolver_CG.h:29
ASolver_CG::flop_count
double flop_count()
returns the floating point operation count.
Definition: asolver_CG-tmpl.h:229
ASolver::InitialGuess
InitialGuess
Definition: asolver.h:31
ASolver_CG::InitialGuess
typename ASolver< AFIELD >::InitialGuess InitialGuess
Definition: asolver_CG.h:22
Field
Container of Field-type object.
Definition: field.h:46
afopr.h
asolver.h
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29