27 bool init = Solver::Factory::Register(
"BiCGStab_DS_L_Cmplx", create_object);
45 #ifdef USE_PARAMETERS_FACTORY
60 const string str_vlevel = params.
get_string(
"verbose_level");
71 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
72 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
73 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_L);
74 err += params.
fetch_double(
"tolerance_for_DynamicSelection_of_L", Tol_L);
138 int& Nconv,
double& diff)
142 double bnorm2 = b.
norm2();
143 double snorm = 1.0 / bnorm2;
144 int bsize = b.
size();
168 bool is_converged =
false;
175 for (
int iter = 0; iter <
m_Niter; iter++) {
196 if (ith == 0)
vout.
detailed(
m_vl,
" iter0: %8d %22.15e\n", nth, diff2 * snorm);
208 if (ith == 0)
vout.
detailed(
m_vl,
" iter1: %8d %22.15e\n", nth, rr * snorm);
246 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
260 for (
int i = 0; i <
m_N_L + 1; ++i) {
261 u[i].reset(Nin, Nvol, Nex);
262 r[i].reset(Nin, Nvol, Nex);
303 dcomplex c_Rayleigh_prev = cmplx(0.0, 0.0);
305 bool is_converged_L =
false;
308 for (
int j = 0; j <
N_L_prev; ++j) {
309 if (!is_converged_L) {
313 dcomplex beta = alpha_prev2 * (rho / rho_prev2);
317 for (
int i = 0; i < j + 1; ++i) {
324 alpha_prev2 = rho_prev2 / conj(gamma);
326 for (
int i = 0; i < j + 1; ++i) {
327 axpy(
r[i], -alpha_prev2,
u[i + 1]);
332 axpy(
x, alpha_prev2,
u[0]);
338 double r_tmp =
r[j].norm2();
339 dcomplex c_Rayleigh =
dotc(
r[j],
r[j + 1]) / r_tmp;
341 dcomplex c_E = (c_Rayleigh - c_Rayleigh_prev) / c_Rayleigh;
343 c_Rayleigh_prev = c_Rayleigh;
353 is_converged_L =
true;
359 valarray<double> sigma(
m_N_L + 1);
360 valarray<dcomplex> gamma_prime(
m_N_L + 1);
366 for (
int j = 1; j < N_L_tmp + 1; ++j) {
367 for (
int i = 1; i < j; ++i) {
370 dcomplex r_ji =
dotc(
r[j],
r[i]);
371 tau[ij] = conj(r_ji) / sigma[i];
372 axpy(
r[j], -tau[ij],
r[i]);
375 sigma[j] =
r[j].norm2();
377 dcomplex r_0j =
dotc(
r[0],
r[j]);
378 gamma_prime[j] = conj(r_0j) / sigma[j];
382 valarray<dcomplex> gamma(
m_N_L + 1);
385 gamma[N_L_tmp] = gamma_prime[N_L_tmp];
387 for (
int j = N_L_tmp - 1; j > 0; --j) {
388 c_tmp = cmplx(0.0, 0.0);
390 for (
int i = j + 1; i < N_L_tmp + 1; ++i) {
392 c_tmp += tau[ji] * gamma[i];
395 gamma[j] = gamma_prime[j] - c_tmp;
400 valarray<dcomplex> gamma_double_prime(
m_N_L);
402 for (
int j = 1; j < N_L_tmp; ++j) {
403 c_tmp = cmplx(0.0, 0.0);
405 for (
int i = j + 1; i < N_L_tmp; ++i) {
407 c_tmp += tau[ji] * gamma[i + 1];
410 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
415 axpy(
r[0], -gamma_prime[N_L_tmp],
r[N_L_tmp]);
416 axpy(
u[0], -gamma[N_L_tmp],
u[N_L_tmp]);
418 for (
int j = 1; j < N_L_tmp; ++j) {
419 axpy(
x, gamma_double_prime[j],
r[j]);
420 axpy(
r[0], -gamma_prime[j],
r[j]);
421 axpy(
u[0], -gamma[j],
u[j]);
void set_parameters_DS_L(const int N_L, const double Tol_L)
void detailed(const char *format,...)
static int get_num_threads()
returns available number of threads.
void Register_string(const string &, const string &)
void solve_init(const Field &, double &)
virtual const Field mult(const Field &)=0
multiplies fermion operator to a given field and returns the resultant field.
BiCGStab(DS_L) algorithm.
void general(const char *format,...)
void reset_field(const Field &)
void Register_int(const string &, const int)
Container of Field-type object.
int index_ij(int i, int j)
void copy(Field &y, const Field &x)
copy(y, x): y = x
static int get_thread_id()
returns thread id.
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
int square_non_zero(const double v)
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.
void aypx(const double a, Field &y, const Field &x)
aypx(y, a, x): y := a * y + x
void solve_step(double &)
void paranoiac(const char *format,...)
void axpy(Field &y, const double a, const Field &x)
axpy(y, a, x): y := a * x + y
void crucial(const char *format,...)
static const std::string class_name
Parameters_Solver_BiCGStab_DS_L_Cmplx()
Base class for linear solver class family.
static bool Register(const std::string &realm, const creator_callback &cb)
int non_negative(const int v)
void Register_double(const string &, const double)
void set_parameters(const Parameters ¶ms)
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.