25 bool init = Solver::Factory::Register(
"GMRES_m_Cmplx", create_object);
42 #ifdef USE_PARAMETERS_FACTORY
57 const string str_vlevel = params.
get_string(
"verbose_level");
67 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
68 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
69 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_M);
130 int& Nconv,
double& diff)
134 double bnorm2 = b.
norm2();
135 double snorm = 1.0 / bnorm2;
136 int bsize = b.
size();
160 bool is_converged =
false;
167 for (
int iter = 0; iter <
m_Niter; iter++) {
183 if (ith == 0)
vout.
detailed(
m_vl,
" iter0: %8d %22.15e\n", nth, diff2 * snorm);
186 Nconv2 =
m_N_M * (iter + 1);
196 if (ith == 0)
vout.
detailed(
m_vl,
" iter1: %8d %22.15e\n", nth, rr * snorm);
234 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
243 for (
int i = 0; i <
m_N_M + 1; ++i) {
244 v[i].reset(Nin, Nvol, Nex);
285 for (
int j = 0; j <
m_N_M; ++j) {
288 for (
int i = 0; i < j + 1; ++i) {
296 for (
int i = 0; i < j + 1; ++i) {
298 axpy(
v[j + 1], -h[ij],
v[i]);
301 double v_norm2 =
v[j + 1].norm2();
304 h[j1j] = sqrt(v_norm2);
306 scal(
v[j + 1], 1.0 / sqrt(v_norm2));
315 for (
int i = 0; i <
m_N_M; ++i) {
328 std::valarray<dcomplex>& h)
332 std::valarray<dcomplex> g(
m_N_M + 1);
337 for (
int i = 0; i <
m_N_M; ++i) {
339 double h_1_r = abs(h[ii]);
342 double h_2_r = abs(h[i1i]);
344 double denomi = sqrt(h_1_r * h_1_r + h_2_r * h_2_r);
346 dcomplex cs = h[ii] / denomi;
347 dcomplex sn = h[i1i] / denomi;
349 for (
int j = i; j <
m_N_M; ++j) {
353 dcomplex const_1_c = conj(cs) * h[ij] + sn * h[i1j];
354 dcomplex const_2_c = -sn * h[ij] + cs * h[i1j];
360 dcomplex const_1_c = conj(cs) * g[i] + sn * g[i + 1];
361 dcomplex const_2_c = -sn * g[i] + cs * g[i + 1];
364 g[i + 1] = const_2_c;
368 for (
int i = m_N_M - 1; i > -1; --i) {
369 for (
int j = i + 1; j <
m_N_M; ++j) {
371 g[i] -= h[ij] * y[j];
void scal(Field &x, const double a)
scal(x, a): x = a * x
void detailed(const char *format,...)
static int get_num_threads()
returns available number of threads.
void Register_string(const string &, const string &)
virtual const Field mult(const Field &)=0
multiplies fermion operator to a given field and returns the resultant field.
void general(const char *format,...)
void Register_int(const string &, const int)
static const std::string class_name
Container of Field-type object.
void solve_init(const Field &, double &)
void copy(Field &y, const Field &x)
copy(y, x): y = x
static int get_thread_id()
returns thread id.
int square_non_zero(const double v)
GMRES(m) algorithm with complex variables.
dcomplex dotc(const Field &y, const Field &x)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=COMPLEX)
static void sync_barrier_all()
barrier among all the threads and nodes.
int index_ij(int i, int j)
void paranoiac(const char *format,...)
Parameters_Solver_GMRES_m_Cmplx()
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.
static bool Register(const std::string &realm, const creator_callback &cb)
void reset_field(const Field &)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
int non_negative(const int v)
void Register_double(const string &, const double)
void min_J(std::valarray< dcomplex > &y, std::valarray< dcomplex > &h)
void set_parameters_GMRES_m(const int N_M)
Base class of fermion operator family.
int fetch_double(const string &key, double &val) const
string get_string(const string &key) const
int fetch_int(const string &key, int &val) const
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)
static void assert_single_thread(const std::string &classname)
assert currently running on single thread.
void solve_step(const Field &, double &)
void set_parameters(const Parameters ¶ms)