25 bool init = Solver::Factory::Register(
"CG", create_object);
35 const string str_vlevel = params.
get_string(
"verbose_level");
44 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
45 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
46 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
88 int& Nconv,
double& diff)
90 double bnorm2 = b.
norm2();
97 bool is_converged =
false;
110 for (
int i_restart = 0; i_restart <
m_Nrestart; i_restart++) {
111 for (
int iter = 0; iter <
m_Niter; iter++) {
143 vout.
crucial(
m_vl,
" iter(final): %8d %22.15e\n", Nconv2, diff2 / bnorm2);
153 diff = sqrt(diff2 / bnorm2);
206 double cr = rr_prev / pap;
213 double rr_ratio = rr / rr_prev;
232 if (flop_fopr < eps) {
237 double flop_axpy =
static_cast<double>(Nin * Nex * 2);
238 double flop_dot =
static_cast<double>(Nin * Nex * 2);
239 double flop_norm =
static_cast<double>(Nin * Nex * 2);
241 double flop_init = flop_fopr + flop_axpy + flop_norm;
242 double flop_step = flop_fopr + flop_dot + 3 * flop_axpy + flop_norm;
243 double flop_true_residual = flop_fopr + flop_axpy + flop_norm;
245 double flop = (flop_norm + flop_init + flop_step *
m_Nconv_count + flop_true_residual
void detailed(const char *format,...)
static double epsilon_criterion()
void solve_init(const Field &, double &)
double dot(const Field &y, const Field &x)
void general(const char *format,...)
void reset_field(const Field &)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Container of Field-type object.
static const std::string class_name
int fetch_double(const string &key, double &value) const
void solve_step(double &)
void copy(Field &y, const Field &x)
copy(y, x): y = x
Standard Conjugate Gradient solver algorithm.
int square_non_zero(const double v)
void set_parameters(const Parameters ¶ms)
int fetch_int(const string &key, int &value) const
virtual double flop_count()
returns the flops per site.
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
void paranoiac(const char *format,...)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void crucial(const char *format,...)
Base class for linear solver class family.
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
int non_negative(const int v)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
Base class of fermion operator family.
string get_string(const string &key) const
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)