Bridge++  Ver. 2.0.2
fprop_Standard_Precond.cpp
Go to the documentation of this file.
2 
5 
6 #include "Fopr/fopr.h"
7 #include "Solver/solver_CG.h"
8 
9 
10 //====================================================================
12 {
13  m_fopr->set_config(config);
14 }
15 
16 
17 //====================================================================
19 {
20  // temporary setup.
21  int Niter = 500;
22  int Nrestart = 100;
23  double Stop_cond = 1.0e-28;
25  solver->set_parameters(Niter, Nrestart, Stop_cond);
26 
27  m_solver = (Solver *)solver;
28  // m_solver->set_parameter_verboselevel(Bridge::DETAILED);
29 }
30 
31 
32 //====================================================================
34 {
35  delete m_solver;
36 }
37 
38 
39 //====================================================================
41  int& Nconv, double& diff)
42 {
43  assert(xq.nin() == b.nin());
44  assert(xq.nvol() == b.nvol());
45  assert(xq.nex() == b.nex());
46 
47  invert_D_prec(xq, b, Nconv, diff);
48  // invert_D_plain(xq,b);
49 }
50 
51 
52 //====================================================================
54  int& Nconv, double& diff)
55 {
56  int NinF = b.nin();
57  int Nvol = b.nvol();
58  int Nex = b.nex();
59  assert(xq.check_size(NinF, Nvol, Nex));
60 
61  Field v(NinF, Nvol, Nex);
62 
63  invert_DdagD_prec(xq, b, Nconv, diff);
64  // invert_DdagD_plain(xq,b);
65 
66  m_fopr->set_mode("DdagD");
67  m_fopr->mult(v, xq);
68  axpy(v, -1.0, b);
69  double vv = v.norm2() / b.norm2();
70  vout.detailed(m_vl, " diff2 = %18.8e\n", vv);
71 }
72 
73 
74 //====================================================================
76  int& Nconv, double& diff)
77 {
78  int NinF = b.nin();
79  int Nvol = b.nvol();
80  int Nex = b.nex();
81  assert(xq.check_size(NinF, Nvol, Nex));
82 
83  Field v2(NinF, Nvol, Nex);
84 
85  m_fopr->set_mode("DdagD_prec");
86 
87  // m_fopr->set_mode("D_prec");
88  m_fopr->mult_dag(v2, b, "D_prec");
89 
90  m_solver->solve(xq, v2, Nconv, diff);
91  vout.detailed(m_vl, " Solver: Nconv = %6d diff = %12.6e\n",
92  Nconv, diff);
93 
94  // m_fopr->set_mode("LU_inv");
95  copy(v2, xq);
96  m_fopr->mult(xq, v2, "Prec");
97 }
98 
99 
100 //====================================================================
102  int& Nconv, double& diff)
103 {
104  int NinF = b.nin();
105  int Nvol = b.nvol();
106  int Nex = b.nex();
107  assert(xq.check_size(NinF, Nvol, Nex));
108 
109  Field v2(NinF, Nvol, Nex);
110 
111  // m_fopr->set_mode("LU_inv");
112  // m_fopr->mult_dag(v2, b);
113  m_fopr->mult_dag(v2, b, "Prec");
114 
115  m_fopr->set_mode("DdagD_prec");
116  m_solver->solve(xq, v2, Nconv, diff);
117  vout.detailed(m_vl, " Solver: Nconv = %6d diff = %12.6e\n",
118  Nconv, diff);
119 
120  // m_fopr->set_mode("LU_inv");
121  copy(v2, xq);
122  // m_fopr->mult(xq, v2);
123  m_fopr->mult(xq, v2, "Prec");
124 }
125 
126 
127 //====================================================================
129  int& Nconv, double& diff)
130 {
131  int NinF = b.nin();
132  int Nvol = b.nvol();
133  int Nex = b.nex();
134  assert(xq.check_size(NinF, Nvol, Nex));
135 
136  Field v2(NinF, Nvol, Nex);
137 
138  m_fopr->set_mode("D");
139  m_fopr->mult_dag(v2, b);
140  m_fopr->set_mode("DdagD");
141 
142  m_solver->solve(xq, v2, Nconv, diff);
143  vout.detailed(m_vl, " Solver: Nconv = %6d diff = %12.6e\n",
144  Nconv, diff);
145 }
146 
147 
148 //====================================================================
150  int& Nconv, double& diff)
151 {
152  m_fopr->set_mode("DdagD");
153 
154  m_solver->solve(xq, b, Nconv, diff);
155  vout.detailed(m_vl, " Solver: Nconv = %6d diff = %12.6e\n",
156  Nconv, diff);
157 }
158 
159 
160 //====================================================================
162 {
163  // return m_solver->flop_count();
164 
165  return 0; // temporary unsupported.
166 }
167 
168 
169 //====================================================================
170 //============================================================END=====
Fprop_Standard_Precond::tidyup
void tidyup()
Definition: fprop_Standard_Precond.cpp:33
AFopr::mult
virtual void mult(AFIELD &, const AFIELD &)
multiplies fermion operator to a given field.
Definition: afopr.h:95
Fprop_Standard_Precond::invert_DdagD_plain
void invert_DdagD_plain(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:149
Fprop_Standard_Precond::m_fopr
Fopr * m_fopr
Definition: fprop_Standard_Precond.h:20
Bridge::BridgeIO::detailed
void detailed(const char *format,...)
Definition: bridgeIO.cpp:219
Field::nex
int nex() const
Definition: field.h:128
Field::check_size
bool check_size(const int nin, const int nvol, const int nex) const
checking size parameters. [23 May 2016 H.Matsufuru]
Definition: field.h:135
Fprop_Standard_Precond::m_solver
Solver * m_solver
Definition: fprop_Standard_Precond.h:21
axpy
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
Definition: field.cpp:380
AFopr::set_mode
virtual void set_mode(std::string mode)
setting the mode of multiplication if necessary. Default implementation here is just to avoid irrelev...
Definition: afopr.h:81
Fprop_Standard_Precond::invert_DdagD_prec
void invert_DdagD_prec(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:101
Field::nin
int nin() const
Definition: field.h:126
Fprop_Standard_Precond::invert_DdagD
void invert_DdagD(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:53
Fprop_Standard_Precond::invert_D_plain
void invert_D_plain(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:128
copy
void copy(Field &y, const Field &x)
copy(y, x): y = x
Definition: field.cpp:212
AFopr::set_config
virtual void set_config(Field *)=0
sets the gauge configuration.
Field::norm2
double norm2() const
Definition: field.cpp:113
Solver::solve
virtual void solve(Field &solution, const Field &source, int &Nconv, double &diff)=0
AFopr::mult_dag
virtual void mult_dag(AFIELD &, const AFIELD &)
hermitian conjugate of mult.
Definition: afopr.h:102
Fprop_Standard_Precond::invert_D
void invert_D(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:40
fprop_Standard_Precond.h
Solver
Base class for linear solver class family.
Definition: solver.h:36
Fprop_Standard_Precond::flop_count
double flop_count()
Definition: fprop_Standard_Precond.cpp:161
Fprop::m_vl
Bridge::VerboseLevel m_vl
Definition: fprop.h:37
Fprop_Standard_Precond::set_config
void set_config(Field *)
Definition: fprop_Standard_Precond.cpp:11
Field::nvol
int nvol() const
Definition: field.h:127
Test_Solver_Wilson::solver
int solver(const std::string &)
Definition: test_Solver_Wilson.cpp:134
Fprop_Standard_Precond::invert_D_prec
void invert_D_prec(Field &, const Field &, int &Nconv, double &diff)
Definition: fprop_Standard_Precond.cpp:75
fopr.h
commonParameters.h
solver_CG.h
Solver_CG
Standard Conjugate Gradient solver algorithm.
Definition: solver_CG.h:38
Field
Container of Field-type object.
Definition: field.h:46
communicator.h
Fprop_Standard_Precond::init
void init()
Definition: fprop_Standard_Precond.cpp:18
Bridge::vout
BridgeIO vout
Definition: bridgeIO.cpp:512