16 #ifdef USE_FACTORY_AUTOREGISTER
18 bool init = Solver_GMRES_m_Cmplx::register_factory();
27 const std::string str_vlevel = params.
get_string(
"verbose_level");
38 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
39 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
40 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
41 err += params.
fetch_bool(
"use_initial_guess", use_init_guess);
42 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_M);
93 vout.
general(
m_vl,
" use_init_guess = %s\n", use_init_guess ?
"true" :
"false");
136 int& Nconv,
double& diff)
138 const double bnorm2 = b.
norm2();
139 const int bsize = b.
size();
145 bool is_converged =
false;
163 Nconv2 += Nconv_unit;
168 for (
int i_restart = 0; i_restart <
m_Nrestart; i_restart++) {
169 for (
int iter = 0; iter <
m_Niter; iter++) {
173 Nconv2 += Nconv_unit *
m_N_M;
205 vout.
crucial(
m_vl,
" iter(final): %8d %22.15e\n", Nconv2, diff2 / bnorm2);
215 diff = sqrt(diff2 / bnorm2);
228 const int Nin = b.
nin();
229 const int Nvol = b.
nvol();
230 const int Nex = b.
nex();
241 for (
int i = 0; i <
m_N_M + 1; ++i) {
242 m_v[i].reset(Nin, Nvol, Nex);
257 for (
int i = 0; i <
m_N_M + 1; ++i) {
288 for (
int j = 0; j <
m_N_M; ++j) {
291 for (
int i = 0; i < j + 1; ++i) {
299 for (
int i = 0; i < j + 1; ++i) {
304 double v_norm2 =
m_v[j + 1].norm2();
307 h[j1j] = cmplx(sqrt(v_norm2), 0.0);
309 scal(
m_v[j + 1], 1.0 / sqrt(v_norm2));
318 for (
int i = 0; i <
m_N_M; ++i) {
331 std::valarray<dcomplex>& h)
335 std::valarray<dcomplex> g(
m_N_M + 1);
340 for (
int i = 0; i <
m_N_M; ++i) {
342 double h_1_r = abs(h[ii]);
345 double h_2_r = abs(h[i1i]);
347 double denomi = sqrt(h_1_r * h_1_r + h_2_r * h_2_r);
349 dcomplex cs = h[ii] / denomi;
350 dcomplex sn = h[i1i] / denomi;
352 for (
int j = i; j <
m_N_M; ++j) {
356 dcomplex const_1_c = conj(cs) * h[ij] + sn * h[i1j];
357 dcomplex const_2_c = -sn * h[ij] + cs * h[i1j];
363 dcomplex const_1_c = conj(cs) * g[i] + sn * g[i + 1];
364 dcomplex const_2_c = -sn * g[i] + cs * g[i + 1];
367 g[i + 1] = const_2_c;
371 for (
int i = m_N_M - 1; i > -1; --i) {
372 for (
int j = i + 1; j <
m_N_M; ++j) {
374 g[i] -= h[ij] * y[j];
390 const int Nin =
m_x.
nin();
392 const int Nex =
m_x.
nex();
401 const double gflop_axpy = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
402 const double gflop_dotc = (Nin * Nex * 4) * ((Nvol * NPE) / 1.0e+9);
403 const double gflop_norm = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
404 const double gflop_scal = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
407 for (
int j = 0; j <
m_N_M; ++j) {
408 for (
int i = 0; i < j + 1; ++i) {
413 const double gflop_init = gflop_fopr + gflop_axpy + gflop_norm;
414 const double gflop_step = m_N_M * gflop_fopr + N_M_part * gflop_dotc
415 + (N_M_part +
m_N_M) * gflop_axpy
417 const double gflop_true_residual = gflop_fopr + gflop_axpy + gflop_norm;
420 const double gflop = gflop_norm + gflop_init
void scal(Field &x, const double a)
scal(x, a): x = a * x
int fetch_bool(const string &key, bool &value) const
void detailed(const char *format,...)
static double epsilon_criterion()
void general(const char *format,...)
static const std::string class_name
Container of Field-type object.
int fetch_double(const string &key, double &value) const
void solve_init(const Field &, double &)
void copy(Field &y, const Field &x)
copy(y, x): y = x
int square_non_zero(const double v)
dcomplex dotc(const Field &y, const Field &x)
int fetch_int(const string &key, int &value) const
virtual double flop_count()
returns the flop in giga unit
int index_ij(const int i, const int j)
void paranoiac(const char *format,...)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void crucial(const char *format,...)
void reset_field(const Field &)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
int non_negative(const int v)
void min_J(std::valarray< dcomplex > &y, std::valarray< dcomplex > &h)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
void set_parameters_GMRES_m(const int N_M)
string get_string(const string &key) const
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)
void solve_step(const Field &, double &)
void set_parameters(const Parameters ¶ms)