16 #ifdef USE_FACTORY_AUTOREGISTER
18 bool init = Solver_BiCGStab_IDS_L_Cmplx::register_factory();
27 const string str_vlevel = params.
get_string(
"verbose_level");
35 double Omega_tolerance;
40 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
41 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
42 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
43 err += params.
fetch_bool(
"use_initial_guess", use_init_guess);
44 err += params.
fetch_double(
"Omega_tolerance", Omega_tolerance);
45 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_L);
46 err += params.
fetch_double(
"tolerance_for_DynamicSelection_of_L", Tol_L);
98 vout.
general(
m_vl,
" use_init_guess = %s\n", use_init_guess ?
"true" :
"false");
160 int& Nconv,
double& diff)
162 const double bnorm2 = b.
norm2();
163 const int bsize = b.
size();
169 bool is_converged =
false;
187 Nconv2 += Nconv_unit;
192 for (
int i_restart = 0; i_restart <
m_Nrestart; i_restart++) {
193 for (
int iter = 0; iter <
m_Niter; iter++) {
230 vout.
crucial(
m_vl,
" iter(final): %8d %22.15e\n", Nconv2, diff2 / bnorm2);
240 diff = sqrt(diff2 / bnorm2);
253 const int Nin = b.
nin();
254 const int Nvol = b.
nvol();
255 const int Nex = b.
nex();
267 for (
int i = 0; i <
m_N_L + 1; ++i) {
268 m_u[i].reset(Nin, Nvol, Nex);
269 m_r[i].reset(Nin, Nvol, Nex);
283 for (
int i = 0; i <
m_N_L + 1; ++i) {
318 dcomplex c_Rayleigh_prev = cmplx(0.0, 0.0);
320 bool is_converged_L =
false;
324 if (!is_converged_L) {
328 dcomplex beta = alpha_prev2 * (rho / rho_prev2);
332 for (
int i = 0; i < j + 1; ++i) {
340 alpha_prev2 = rho_prev2 / conj(gamma);
342 for (
int i = 0; i < j + 1; ++i) {
354 double r_tmp =
m_r[j].norm2();
355 dcomplex c_Rayleigh =
dotc(
m_r[j],
m_r[j + 1]) / r_tmp;
357 dcomplex c_E = (c_Rayleigh - c_Rayleigh_prev) / c_Rayleigh;
360 c_Rayleigh_prev = c_Rayleigh;
370 is_converged_L =
true;
376 std::vector<double> sigma(
m_N_L + 1);
377 std::vector<dcomplex> gamma_prime(
m_N_L + 1);
380 std::vector<dcomplex> tau(
m_N_L * (
m_N_L + 1));
382 const double sigma_0 =
m_r[0].norm2();
384 for (
int j = 1; j < N_L_tmp + 1; ++j) {
385 for (
int i = 1; i < j; ++i) {
389 tau[ij] = conj(r_ji) / sigma[i];
393 sigma[j] =
m_r[j].norm2();
396 gamma_prime[j] = conj(r_0j) / sigma[j];
399 double abs_rho = abs(r_0j) / sqrt(sigma[j] * sigma_0);
406 std::vector<dcomplex> gamma(
m_N_L + 1);
407 gamma[N_L_tmp] = gamma_prime[N_L_tmp];
409 for (
int j = N_L_tmp - 1; j > 0; --j) {
410 dcomplex c_tmp = cmplx(0.0, 0.0);
412 for (
int i = j + 1; i < N_L_tmp + 1; ++i) {
414 c_tmp += tau[ji] * gamma[i];
417 gamma[j] = gamma_prime[j] - c_tmp;
422 std::vector<dcomplex> gamma_double_prime(
m_N_L);
424 for (
int j = 1; j < N_L_tmp; ++j) {
425 dcomplex c_tmp = cmplx(0.0, 0.0);
427 for (
int i = j + 1; i < N_L_tmp; ++i) {
429 c_tmp += tau[ji] * gamma[i + 1];
432 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
437 axpy(
m_r[0], -gamma_prime[N_L_tmp],
m_r[N_L_tmp]);
440 for (
int j = 1; j < N_L_tmp; ++j) {
463 m_N_L_prev = N_L_tmp;
479 const int Nin =
m_x.
nin();
481 const int Nex =
m_x.
nex();
490 const double gflop_axpy = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
491 const double gflop_dotc = (Nin * Nex * 4) * ((Nvol * NPE) / 1.0e+9);
492 const double gflop_norm = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
496 const double gflop_init = gflop_fopr + gflop_axpy + gflop_norm;
497 const double gflop_step_BiCG_part = 2 * N_L_prev_total * gflop_fopr
498 + 3 * N_L_prev_total * gflop_dotc
500 + N_L_prev_total * gflop_norm;
501 const double gflop_step_L_part = (
m_N_L_part_count + N_L_prev_total) * gflop_dotc
504 const double gflop_step = gflop_step_BiCG_part + gflop_step_L_part;
505 const double gflop_true_residual = gflop_fopr + gflop_axpy + gflop_norm;
507 const double gflop = gflop_norm + gflop_init + gflop_step + gflop_true_residual * (
m_Nrestart_count + 1)
int fetch_bool(const string &key, bool &value) const
void detailed(const char *format,...)
static double epsilon_criterion()
void set_parameters_DS_L(const int N_L, const double Tol_L)
void general(const char *format,...)
Container of Field-type object.
int fetch_double(const string &key, double &value) const
int index_ij(const int i, const int j)
void copy(Field &y, const Field &x)
copy(y, x): y = x
void solve_init(const Field &, double &)
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
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
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
static const std::string class_name
void crucial(const char *format,...)
void set_parameters_BiCGStab_series(const double Omega_tolerance)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
void solve_step(double &)
void reset_field(const Field &)
int non_negative(const int v)
void set_parameters(const Parameters ¶ms)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
string get_string(const string &key) const
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)