27 bool init = Solver::Factory::Register(
"GMRES_m_Cmplx", create_object);
44 #ifdef USE_PARAMETERS_FACTORY
59 const string str_vlevel = params.
get_string(
"verbose_level");
69 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
70 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
71 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_M);
132 int& Nconv,
double& diff)
134 double bnorm2 = b.
norm2();
135 double snorm = 1.0 / bnorm2;
136 int bsize = b.
size();
152 bool is_converged =
false;
157 for (
int iter = 0; iter <
m_Niter; iter++) {
158 if (is_converged)
break;
171 Nconv2 =
m_N_M * (iter + 1);
214 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
223 for (
int i = 0; i <
m_N_M + 1; ++i) {
224 v[i].reset(Nin, Nvol, Nex);
266 for (
int j = 0; j <
m_N_M; ++j) {
269 for (
int i = 0; i < j + 1; ++i) {
277 for (
int i = 0; i < j + 1; ++i) {
279 axpy(
v[j + 1], -h[ij],
v[i]);
282 double v_norm2 =
v[j + 1].norm2();
285 h[j1j] = sqrt(v_norm2);
287 scal(
v[j + 1], 1.0 / sqrt(v_norm2));
296 for (
int i = 0; i <
m_N_M; ++i) {
309 valarray<dcomplex>& h)
313 valarray<dcomplex> g(
m_N_M + 1);
318 for (
int i = 0; i <
m_N_M; ++i) {
320 double h_1_r = abs(h[ii]);
323 double h_2_r = abs(h[i1i]);
325 double denomi = sqrt(h_1_r * h_1_r + h_2_r * h_2_r);
327 dcomplex cs = h[ii] / denomi;
328 dcomplex sn = h[i1i] / denomi;
330 for (
int j = i; j <
m_N_M; ++j) {
334 dcomplex const_1_c = conj(cs) * h[ij] + sn * h[i1j];
335 dcomplex const_2_c = -sn * h[ij] + cs * h[i1j];
341 dcomplex const_1_c = conj(cs) * g[i] + sn * g[i + 1];
342 dcomplex const_2_c = -sn * g[i] + cs * g[i + 1];
345 g[i + 1] = const_2_c;
349 for (
int i = m_N_M - 1; i > -1; --i) {
350 for (
int j = i + 1; j <
m_N_M; ++j) {
352 g[i] -= h[ij] * y[j];
void scal(Field &x, const double a)
scal(x, a): x = a * x
void detailed(const char *format,...)
void Register_string(const string &, const string &)
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
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)
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 &)
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 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)