Go to the documentation of this file.
16 #ifdef USE_FACTORY_AUTOREGISTER
18 bool init = Solver_GMRES_m_Cmplx::register_factory();
39 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
40 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
41 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
42 err += params.
fetch_bool(
"use_initial_guess", use_init_guess);
43 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_M);
107 vout.
general(
m_vl,
" use_init_guess = %s\n", use_init_guess ?
"true" :
"false");
151 const double Stop_cond,
152 const bool use_init_guess,
162 vout.
general(
m_vl,
" use_init_guess = %s\n", use_init_guess ?
"true" :
"false");
191 int& Nconv,
double& diff)
193 const double bnorm2 = b.
norm2();
194 const int bsize = b.
size();
200 bool is_converged =
false;
218 Nconv2 += Nconv_unit;
223 for (
int i_restart = 0; i_restart <
m_Nrestart; i_restart++) {
224 for (
int iter = 0; iter <
m_Niter; iter++) {
228 Nconv2 += Nconv_unit *
m_N_M;
260 vout.
crucial(
m_vl,
" iter(final): %8d %22.15e\n", Nconv2, diff2 / bnorm2);
270 diff = sqrt(diff2 / bnorm2);
283 const int Nin = b.
nin();
284 const int Nvol = b.
nvol();
285 const int Nex = b.
nex();
296 for (
int i = 0; i <
m_N_M + 1; ++i) {
297 m_v[i].reset(Nin, Nvol, Nex);
312 for (
int i = 0; i <
m_N_M + 1; ++i) {
343 for (
int j = 0; j <
m_N_M; ++j) {
346 for (
int i = 0; i < j + 1; ++i) {
354 for (
int i = 0; i < j + 1; ++i) {
359 double v_norm2 =
m_v[j + 1].norm2();
362 h[j1j] = cmplx(sqrt(v_norm2), 0.0);
364 scal(
m_v[j + 1], 1.0 / sqrt(v_norm2));
373 for (
int i = 0; i <
m_N_M; ++i) {
386 std::valarray<dcomplex>& h)
390 std::valarray<dcomplex> g(
m_N_M + 1);
395 for (
int i = 0; i <
m_N_M; ++i) {
397 double h_1_r = abs(h[ii]);
400 double h_2_r = abs(h[i1i]);
402 double denomi = sqrt(h_1_r * h_1_r + h_2_r * h_2_r);
404 dcomplex cs = h[ii] / denomi;
405 dcomplex sn = h[i1i] / denomi;
407 for (
int j = i; j <
m_N_M; ++j) {
411 dcomplex const_1_c = conj(cs) * h[ij] + sn * h[i1j];
412 dcomplex const_2_c = -sn * h[ij] + cs * h[i1j];
418 dcomplex const_1_c = conj(cs) * g[i] + sn * g[i + 1];
419 dcomplex const_2_c = -sn * g[i] + cs * g[i + 1];
422 g[i + 1] = const_2_c;
426 for (
int i =
m_N_M - 1; i > -1; --i) {
427 for (
int j = i + 1; j <
m_N_M; ++j) {
429 g[i] -= h[ij] * y[j];
445 const int Nin =
m_x.
nin();
447 const int Nex =
m_x.
nex();
456 const double gflop_axpy = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
457 const double gflop_dotc = (Nin * Nex * 4) * ((Nvol * NPE) / 1.0e+9);
458 const double gflop_norm = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
459 const double gflop_scal = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
462 for (
int j = 0; j <
m_N_M; ++j) {
463 for (
int i = 0; i < j + 1; ++i) {
468 const double gflop_init = gflop_fopr + gflop_axpy + gflop_norm + gflop_scal;
469 const double gflop_step =
m_N_M * gflop_fopr + N_M_part * gflop_dotc
470 + (N_M_part +
m_N_M) * gflop_axpy
473 const double gflop_true_residual = gflop_fopr + gflop_axpy + gflop_norm;
476 const double gflop = gflop_norm + gflop_init
477 + gflop_step * N_iter
void set_bool(const string &key, const bool value)
void solve_step(const Field &, double &)
static const std::string class_name
DEPRECATED void set_parameters_GMRES_m(const int N_M)
void set_string(const string &key, const string &value)
virtual void mult(AFIELD &, const AFIELD &)
multiplies fermion operator to a given field.
void set_double(const string &key, const double value)
void detailed(const char *format,...)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
int non_negative(const int v)
int fetch_bool(const string &key, bool &value) const
void copy(Field &y, const Field &x)
copy(y, x): y = x
void solve_init(const Field &, double &)
void paranoiac(const char *format,...)
int index_ij(const int i, const int j)
void get_parameters(Parameters ¶ms) const
virtual double flop_count()
returns the number of floating point operations.
int square_non_zero(const double v)
dcomplex dotc(const Field &y, const Field &x)
void reset_field(const Field &)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
void min_J(std::valarray< dcomplex > &y, std::valarray< dcomplex > &h)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
static VerboseLevel set_verbose_level(const std::string &str)
Bridge::VerboseLevel m_vl
void set_int(const string &key, const int value)
void scal(Field &x, const double a)
scal(x, a): x = a * x
int fetch_string(const string &key, string &value) const
int fetch_double(const string &key, double &value) const
void crucial(const char *format,...)
Container of Field-type object.
void set_parameters(const Parameters ¶ms)
int fetch_int(const string &key, int &value) const
void general(const char *format,...)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
static std::string get_verbose_level(const VerboseLevel vl)
static double epsilon_criterion()