Bridge++  Ver. 2.0.2
asolver_SAP_MINRES.h
Go to the documentation of this file.
1 
10 #ifndef ASOLVER_SAP_MINRES_H
11 #define ASOLVER_SAP_MINRES_H
12 
13 #include <cstdio>
14 #include <cstdlib>
15 #include <vector>
16 using std::vector;
17 #include <string>
18 using std::string;
19 
20 #include "lib_alt/Solver/asolver.h"
21 #include "lib_alt/Fopr/afopr_dd.h"
23 
24 
25 template<typename AFIELD>
26 class ASolver_SAP_MINRES : public ASolver<AFIELD>
27 {
28  public:
29  typedef typename AFIELD::real_t real_t;
32  static const std::string class_name;
33 
34  protected:
35 
37 
39 
40  int m_Niter;
42 
44  int m_nconv;
45 
48 
51 
52  using complex_t = typename AFIELD::complex_t;
53 
54  // aligned_vector<real_t> m_r2_block;
55  // aligned_vector<real_t> m_p2_block;
56  // aligned_vector<complex_t> m_alpha_block;
57  std::vector<real_t> m_r2_block;
58  std::vector<real_t> m_p2_block;
59  std::vector<complex_t> m_alpha_block;
60 
61 
62  public:
65  : m_Niter(0), m_Stop_cond(-1.0)
66  {
67  m_fopr = fopr;
68  m_block_index = block_index;
69  this->init();
70  }
71 
73  : m_Niter(0), m_Stop_cond(-1.0)
74  {
75  vout.crucial(m_vl, "partial construct is not allowed for Asolver_SAP_MINRES\n");
76  abort();
77  m_fopr = nullptr;
78  m_block_index = nullptr;
79  }
80 
82  ~ASolver_SAP_MINRES() { this->tidyup(); }
83 
85  void set_block(block_index_t *block_index)
86  {
87  m_block_index = block_index;
88  this->init();
89  }
90 
92  void set_parameters(const Parameters& params);
93 
95  void set_parameters(const int Niter, const real_t Stop_cond);
96 
98  void solve(AFIELD& xq, const AFIELD& b, int& nconv, real_t& diff, const int eo);
99 
102 
104  double flop_count();
105 
106 
107  protected:
108 
109  void init(void);
110 
111  void tidyup(void);
112 
113  private:
114 
115  double m_flop_each;
116  void calc_flop_each();
117 
118 #ifdef USE_FACTORY
119  private:
120  static ASolver<AFIELD> *create_object(AFopr<AFIELD> *afopr)
121  {
122  return new ASolver_SAP_MINRES<AFIELD>(afopr);
123  }
124 
125  public:
126  static bool register_factory()
127  {
128  return ASolver<AFIELD>::Factory_fopr::Register("SAP_MINRES", create_object);
129  }
130 #endif
131 };
132 
133 #endif // ASOLVER_SAP_MINRES_H
134 
135 //============================================================END=====
ASolver_SAP_MINRES::m_Stop_cond
real_t m_Stop_cond
stopping criterion (squared).
Definition: asolver_SAP_MINRES.h:41
ASolver_SAP_MINRES::m_p2_block
std::vector< real_t > m_p2_block
Definition: asolver_SAP_MINRES.h:58
ASolver_SAP_MINRES
Definition: asolver_SAP_MINRES.h:26
AFopr
Definition: afopr.h:48
ASolver
Definition: asolver.h:23
Parameters
Class for parameters.
Definition: parameters.h:46
ASolver_SAP_MINRES::class_name
static const std::string class_name
Definition: asolver_SAP_MINRES.h:32
ASolver_SAP_MINRES::m_p
AFIELD m_p
Definition: asolver_SAP_MINRES.h:50
ASolver_SAP_MINRES::solve
void solve(AFIELD &xq, const AFIELD &b, int &nconv, real_t &diff, const int eo)
solver main.
Definition: asolver_SAP_MINRES-tmpl.h:99
ASolver_SAP_MINRES::m_block_index
const block_index_t * m_block_index
Definition: asolver_SAP_MINRES.h:36
ASolver_SAP_MINRES::calc_flop_each
void calc_flop_each()
Definition: asolver_SAP_MINRES-tmpl.h:183
ASolver_SAP_MINRES::m_fopr
AFopr_dd< AFIELD > * m_fopr
need mult_sap()
Definition: asolver_SAP_MINRES.h:38
ASolver_SAP_MINRES::complex_t
typename AFIELD::complex_t complex_t
Definition: asolver_SAP_MINRES.h:52
ASolver_SAP_MINRES::ASolver_SAP_MINRES
ASolver_SAP_MINRES(AFopr_dd< AFIELD > *fopr, const block_index_t *block_index)
constructor.
Definition: asolver_SAP_MINRES.h:64
real_t
double real_t
Definition: bridgeQXS_Clover_coarse_double.cpp:16
AIndex_block_lex< real_t, AFIELD::IMPL >
AFopr_dd
Base class of fermion operator family.
Definition: afopr_dd.h:24
Field::real_t
double real_t
Definition: field.h:51
afopr_dd.h
ASolver_SAP_MINRES::ASolver_SAP_MINRES
ASolver_SAP_MINRES(AFopr< AFIELD > *fopr)
Definition: asolver_SAP_MINRES.h:72
ASolver_SAP_MINRES::get_afopr
AFopr< AFIELD > * get_afopr()
returns the pointer to the fermion operator.
Definition: asolver_SAP_MINRES.h:101
ASolver::m_vl
Bridge::VerboseLevel m_vl
Definition: asolver.h:26
ASolver_SAP_MINRES::set_parameters
void set_parameters(const Parameters &params)
setting parameters by a Parameter object.
Definition: asolver_SAP_MINRES-tmpl.h:52
ASolver_SAP_MINRES::flop_count
double flop_count()
returns the floating point operation count.
Definition: asolver_SAP_MINRES-tmpl.h:175
ASolver_SAP_MINRES::m_flop_each
double m_flop_each
Definition: asolver_SAP_MINRES.h:115
ASolver_SAP_MINRES::m_alpha_block
std::vector< complex_t > m_alpha_block
Definition: asolver_SAP_MINRES.h:59
ASolver_SAP_MINRES::m_Niter
int m_Niter
maximum iteration number.
Definition: asolver_SAP_MINRES.h:40
ASolver_SAP_MINRES::real_t
AFIELD::real_t real_t
Definition: asolver_SAP_MINRES.h:29
ASolver_SAP_MINRES::m_nconv
int m_nconv
to remember convergence iteration to provide flop count.
Definition: asolver_SAP_MINRES.h:44
ASolver_SAP_MINRES::m_r2_block
std::vector< real_t > m_r2_block
Definition: asolver_SAP_MINRES.h:57
ASolver_SAP_MINRES::init
void init(void)
Definition: asolver_SAP_MINRES-tmpl.h:18
aindex_block_lex_base.h
ASolver_SAP_MINRES::ASolver_SAP_MINRES
ASolver_SAP_MINRES()
calling constructor without fermion operator is forbidden.
Definition: asolver_SAP_MINRES.h:47
complex_t
ComplexTraits< double >::complex_t complex_t
Definition: afopr_Clover_coarse_double.cpp:23
Bridge::BridgeIO::crucial
void crucial(const char *format,...)
Definition: bridgeIO.cpp:180
ASolver_SAP_MINRES::tidyup
void tidyup(void)
Definition: asolver_SAP_MINRES-tmpl.h:43
Field
Container of Field-type object.
Definition: field.h:46
ASolver_SAP_MINRES::~ASolver_SAP_MINRES
~ASolver_SAP_MINRES()
destructor.
Definition: asolver_SAP_MINRES.h:82
asolver.h
ASolver_SAP_MINRES::m_r
AFIELD m_r
working vectors.
Definition: asolver_SAP_MINRES.h:50
ASolver::real_t
AFIELD::real_t real_t
Definition: asolver.h:29
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512
ASolver_SAP_MINRES::set_block
void set_block(block_index_t *block_index)
setting block.
Definition: asolver_SAP_MINRES.h:85
ASolver_SAP_MINRES::block_index_t
AIndex_block_lex< real_t, AFIELD::IMPL > block_index_t
Definition: asolver_SAP_MINRES.h:30