26 bool init = Solver::Factory::Register(
"BiCGStab_DS_L_Cmplx", create_object);
44 #ifdef USE_PARAMETERS_FACTORY
59 const string str_vlevel = params.
get_string(
"verbose_level");
70 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
71 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
72 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_L);
73 err += params.
fetch_double(
"tolerance_for_DynamicSelection_of_L", Tol_L);
137 int& Nconv,
double& diff)
139 double bnorm2 = b.
norm2();
140 double snorm = 1.0 / bnorm2;
141 int bsize = b.
size();
157 bool is_converged =
false;
162 for (
int iter = 0; iter <
m_Niter; iter++) {
163 if (is_converged)
break;
220 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
230 for (
int i = 0; i <
m_N_L + 1; ++i) {
231 u[i].reset(Nin, Nvol, Nex);
232 r[i].reset(Nin, Nvol, Nex);
277 dcomplex c_Rayleigh_prev = cmplx(0.0, 0.0);
279 bool is_converged_L =
false;
282 for (
int j = 0; j <
N_L_prev; ++j) {
283 if (!is_converged_L) {
287 dcomplex beta = alpha_prev2 * (rho / rho_prev2);
291 for (
int i = 0; i < j + 1; ++i) {
298 alpha_prev2 = rho_prev2 / conj(gamma);
300 for (
int i = 0; i < j + 1; ++i) {
301 axpy(
r[i], -alpha_prev2,
u[i + 1]);
306 axpy(
x, alpha_prev2,
u[0]);
312 double r_tmp =
r[j].norm2();
313 dcomplex c_Rayleigh =
dotc(
r[j],
r[j + 1]) / r_tmp;
315 dcomplex c_E = (c_Rayleigh - c_Rayleigh_prev) / c_Rayleigh;
317 c_Rayleigh_prev = c_Rayleigh;
327 is_converged_L =
true;
333 std::vector<double> sigma(
m_N_L + 1);
334 std::vector<dcomplex> gamma_prime(
m_N_L + 1);
337 std::vector<dcomplex> tau(
m_N_L * (
m_N_L + 1));
340 for (
int j = 1; j < N_L_tmp + 1; ++j) {
341 for (
int i = 1; i < j; ++i) {
344 dcomplex r_ji =
dotc(
r[j],
r[i]);
345 tau[ij] = conj(r_ji) / sigma[i];
346 axpy(
r[j], -tau[ij],
r[i]);
349 sigma[j] =
r[j].norm2();
351 dcomplex r_0j =
dotc(
r[0],
r[j]);
352 gamma_prime[j] = conj(r_0j) / sigma[j];
356 std::vector<dcomplex> gamma(
m_N_L + 1);
359 gamma[N_L_tmp] = gamma_prime[N_L_tmp];
361 for (
int j = N_L_tmp - 1; j > 0; --j) {
362 c_tmp = cmplx(0.0, 0.0);
364 for (
int i = j + 1; i < N_L_tmp + 1; ++i) {
366 c_tmp += tau[ji] * gamma[i];
369 gamma[j] = gamma_prime[j] - c_tmp;
374 std::vector<dcomplex> gamma_double_prime(
m_N_L);
376 for (
int j = 1; j < N_L_tmp; ++j) {
377 c_tmp = cmplx(0.0, 0.0);
379 for (
int i = j + 1; i < N_L_tmp; ++i) {
381 c_tmp += tau[ji] * gamma[i + 1];
384 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
389 axpy(
r[0], -gamma_prime[N_L_tmp],
r[N_L_tmp]);
390 axpy(
u[0], -gamma[N_L_tmp],
u[N_L_tmp]);
392 for (
int j = 1; j < N_L_tmp; ++j) {
393 axpy(
x, gamma_double_prime[j],
r[j]);
394 axpy(
r[0], -gamma_prime[j],
r[j]);
395 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,...)
void Register_string(const string &, const string &)
void solve_init(const Field &, double &)
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
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)
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)
virtual void mult(Field &, const Field &)=0
multiplies fermion operator to a given field (2nd argument)
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.