16 #ifdef USE_FACTORY_AUTOREGISTER
18 bool init = Solver_BiCGStab_L_Cmplx::register_factory();
27 const string str_vlevel = params.
get_string(
"verbose_level");
35 double Omega_tolerance;
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_double(
"Omega_tolerance", Omega_tolerance);
44 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_L);
96 vout.
general(
m_vl,
" use_init_guess = %s\n", use_init_guess ?
"true" :
"false");
155 int& Nconv,
double& diff)
157 const double bnorm2 = b.
norm2();
158 const int bsize = b.
size();
164 bool is_converged =
false;
182 Nconv2 += Nconv_unit;
187 for (
int i_restart = 0; i_restart <
m_Nrestart; i_restart++) {
188 for (
int iter = 0; iter <
m_Niter; iter++) {
192 Nconv2 += 2 * Nconv_unit *
m_N_L;
224 vout.
crucial(
m_vl,
" iter(final): %8d %22.15e\n", Nconv2, diff2 / bnorm2);
234 diff = sqrt(diff2 / bnorm2);
247 const int Nin = b.
nin();
248 const int Nvol = b.
nvol();
249 const int Nex = b.
nex();
261 for (
int i = 0; i <
m_N_L + 1; ++i) {
262 m_u[i].reset(Nin, Nvol, Nex);
263 m_r[i].reset(Nin, Nvol, Nex);
277 for (
int i = 0; i <
m_N_L + 1; ++i) {
308 for (
int j = 0; j <
m_N_L; ++j) {
312 dcomplex beta = alpha_prev2 * (rho / rho_prev2);
316 for (
int i = 0; i < j + 1; ++i) {
323 alpha_prev2 = rho_prev2 / conj(gamma);
325 for (
int i = 0; i < j + 1; ++i) {
335 std::vector<double> sigma(m_N_L + 1);
336 std::vector<dcomplex> gamma_prime(m_N_L + 1);
339 std::vector<dcomplex> tau(m_N_L * (m_N_L + 1));
341 const double sigma_0 =
m_r[0].norm2();
343 for (
int j = 1; j < m_N_L + 1; ++j) {
344 for (
int i = 1; i < j; ++i) {
348 tau[ij] = conj(r_ji) / sigma[i];
352 sigma[j] =
m_r[j].norm2();
355 gamma_prime[j] = conj(r_0j) / sigma[j];
358 double abs_rho = abs(r_0j) / sqrt(sigma[j] * sigma_0);
365 std::vector<dcomplex> gamma(m_N_L + 1);
370 for (
int j = m_N_L - 1; j > 0; --j) {
371 dcomplex c_tmp = cmplx(0.0, 0.0);
373 for (
int i = j + 1; i < m_N_L + 1; ++i) {
375 c_tmp += tau[ji] * gamma[i];
378 gamma[j] = gamma_prime[j] - c_tmp;
383 std::vector<dcomplex> gamma_double_prime(m_N_L);
385 for (
int j = 1; j <
m_N_L; ++j) {
386 dcomplex c_tmp = cmplx(0.0, 0.0);
388 for (
int i = j + 1; i <
m_N_L; ++i) {
390 c_tmp += tau[ji] * gamma[i + 1];
393 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
398 axpy(
m_r[0], -gamma_prime[m_N_L],
m_r[m_N_L]);
401 for (
int j = 1; j <
m_N_L; ++j) {
428 const int Nin =
m_x.
nin();
430 const int Nex =
m_x.
nex();
439 const double gflop_axpy = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
440 const double gflop_dotc = (Nin * Nex * 4) * ((Nvol * NPE) / 1.0e+9);
441 const double gflop_norm = (Nin * Nex * 2) * ((Nvol * NPE) / 1.0e+9);
444 for (
int j = 0; j <
m_N_L; ++j) {
445 for (
int i = 0; i < j + 1; ++i) {
450 const double gflop_init = gflop_fopr + gflop_axpy + gflop_norm;
451 const double gflop_step_BiCG_part = 2 * m_N_L * gflop_fopr
452 + 2 * m_N_L * gflop_dotc
453 + (m_N_L + 2 * N_L_part) * gflop_axpy;
454 const double gflop_step_L_part = (N_L_part +
m_N_L) * gflop_dotc
455 + (N_L_part + 3 * m_N_L) * gflop_axpy
456 + (m_N_L + 1) * gflop_norm;
457 const double gflop_step = gflop_step_BiCG_part + gflop_step_L_part;
458 const double gflop_true_residual = gflop_fopr + gflop_axpy + gflop_norm;
461 const double gflop = gflop_norm + gflop_init + gflop_step * N_iter + gflop_true_residual * (
m_Nrestart_count + 1)
int fetch_bool(const string &key, bool &value) const
static const std::string class_name
void detailed(const char *format,...)
static double epsilon_criterion()
void general(const char *format,...)
void set_parameters_L(const int N_L)
void solve_step(double &)
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)
void set_parameters(const Parameters ¶ms)
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 set_parameters_BiCGStab_series(const double Omega_tolerance)
void paranoiac(const char *format,...)
void reset(const int Nin, const int Nvol, const int Nex, const element_type cmpl=Element_type::COMPLEX)
int index_ij(const int i, const int j)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void crucial(const char *format,...)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
int non_negative(const int v)
static void assert_single_thread(const std::string &class_name)
assert currently running on single thread.
string get_string(const string &key) const
void reset_field(const Field &)
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)