27 bool init = Solver::Factory::Register(
"BiCGStab_L_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_L);
132 int& Nconv,
double& diff)
136 double bnorm2 = b.
norm2();
137 double snorm = 1.0 / bnorm2;
138 int bsize = b.
size();
162 bool is_converged =
false;
169 for (
int iter = 0; iter <
m_Niter; iter++) {
187 if (ith == 0)
vout.
detailed(
m_vl,
" iter0: %8d %22.15e\n", nth, diff2 * snorm);
199 if (ith == 0)
vout.
detailed(
m_vl,
" iter1: %8d %22.15e\n", nth, rr * snorm);
238 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
252 for (
int i = 0; i <
m_N_L + 1; ++i) {
253 u[i].reset(Nin, Nvol, Nex);
254 r[i].reset(Nin, Nvol, Nex);
292 for (
int j = 0; j <
m_N_L; ++j) {
296 dcomplex beta = alpha_prev2 * (rho / rho_prev2);
300 for (
int i = 0; i < j + 1; ++i) {
307 alpha_prev2 = rho_prev2 / conj(gamma);
309 for (
int i = 0; i < j + 1; ++i) {
310 axpy(
r[i], -alpha_prev2,
u[i + 1]);
315 axpy(
x, alpha_prev2,
u[0]);
319 valarray<double> sigma(m_N_L + 1);
320 valarray<dcomplex> gamma_prime(m_N_L + 1);
323 valarray<dcomplex> tau(m_N_L * (m_N_L + 1));
326 for (
int j = 1; j < m_N_L + 1; ++j) {
327 for (
int i = 1; i < j; ++i) {
330 dcomplex r_ji =
dotc(
r[j],
r[i]);
331 tau[ij] = conj(r_ji) / sigma[i];
332 axpy(
r[j], -tau[ij],
r[i]);
335 sigma[j] =
r[j].norm2();
337 dcomplex r_0j =
dotc(
r[0],
r[j]);
338 gamma_prime[j] = conj(r_0j) / sigma[j];
342 valarray<dcomplex> gamma(m_N_L + 1);
347 for (
int j = m_N_L - 1; j > 0; --j) {
348 c_tmp = cmplx(0.0, 0.0);
350 for (
int i = j + 1; i < m_N_L + 1; ++i) {
352 c_tmp += tau[ji] * gamma[i];
355 gamma[j] = gamma_prime[j] - c_tmp;
360 valarray<dcomplex> gamma_double_prime(m_N_L);
362 for (
int j = 1; j <
m_N_L; ++j) {
363 c_tmp = cmplx(0.0, 0.0);
365 for (
int i = j + 1; i <
m_N_L; ++i) {
367 c_tmp += tau[ji] * gamma[i + 1];
370 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
375 axpy(
r[0], -gamma_prime[m_N_L],
r[m_N_L]);
376 axpy(
u[0], -gamma[m_N_L],
u[m_N_L]);
378 for (
int j = 1; j <
m_N_L; ++j) {
379 axpy(
x, gamma_double_prime[j],
r[j]);
380 axpy(
r[0], -gamma_prime[j],
r[j]);
381 axpy(
u[0], -gamma[j],
u[j]);
static const std::string class_name
void detailed(const char *format,...)
static int get_num_threads()
returns available number of threads.
void Register_string(const string &, const string &)
int index_ij(int i, int j)
virtual const Field mult(const Field &)=0
multiplies fermion operator to a given field and returns the resultant field.
void general(const char *format,...)
void Register_int(const string &, const int)
void set_parameters_L(const int N_L)
void solve_step(double &)
Container of Field-type object.
void solve_init(const Field &, double &)
void copy(Field &y, const Field &x)
copy(y, x): y = x
static int get_thread_id()
returns thread id.
int square_non_zero(const double v)
void set_parameters(const Parameters ¶ms)
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 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,...)
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)
Base class of fermion operator family.
int fetch_double(const string &key, double &val) const
string get_string(const string &key) const
void reset_field(const Field &)
int fetch_int(const string &key, int &val) const
Parameters_Solver_BiCGStab_L_Cmplx()
Bridge::VerboseLevel m_vl
static VerboseLevel set_verbose_level(const std::string &str)
void solve(Field &solution, const Field &source, int &Nconv, double &diff)
static void assert_single_thread(const std::string &classname)
assert currently running on single thread.