18 #ifdef USE_PARAMETERS_FACTORY
30 bool init = Solver::Factory::Register(
"BiCGStab_DS_L_Cmplx", create_object);
48 #ifdef USE_PARAMETERS_FACTORY
61 const string str_vlevel = params.
get_string(
"verbose_level");
72 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
73 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
74 err += params.
fetch_int(
"number_of_orthonormal_vectors", N_L);
75 err += params.
fetch_double(
"tolerance_for_DynamicSelection_of_L", Tol_L);
78 vout.
crucial(
m_vl,
"Solver_BiCGStab_DS_L_Cmplx: fetch error, input parameter not found.\n");
102 vout.
crucial(
m_vl,
"Solver_BiCGStab_DS_L_Cmplx: parameter range check failed.\n");
125 vout.
crucial(
m_vl,
"Solver_BiCGStab_DS_L_Cmplx: parameter range check failed.\n");
137 int& Nconv,
double& diff)
146 double snorm = 1.0 / b.
norm2();
157 for (
int iter = 0; iter <
m_Niter; iter++) {
201 if ((
s.
nin() != Nin) || (
s.
nvol() != Nvol) || (
s.
nex() != Nex)) {
215 for (
int i = 0; i <
m_N_L + 1; ++i) {
216 u[i].reset(Nin, Nvol, Nex);
217 r[i].reset(Nin, Nvol, Nex);
237 rho_p = cmplx(1.0, 0.0);
250 double const_r, const_i, r_tmp;
253 dcomplex c_Rayleigh_p = cmplx(0.0, 0.0);
258 for (
int j = 0; j <
N_L_p; ++j) {
261 dcomplex rho = cmplx(const_r, -const_i);
266 for (
int i = 0; i < j + 1; ++i) {
276 dcomplex gamma = cmplx(const_r, -const_i);
280 for (
int i = 0; i < j + 1; ++i) {
299 dcomplex c_Rayleigh = cmplx(const_r, const_i) / r_tmp;
301 dcomplex c_E = (c_Rayleigh - c_Rayleigh_p) / c_Rayleigh;
303 c_Rayleigh_p = c_Rayleigh;
319 valarray<double> sigma(
m_N_L + 1);
320 valarray<dcomplex> gamma_prime(
m_N_L + 1);
326 for (
int j = 1; j < N_L_tmp + 1; ++j) {
327 for (
int i = 1; i < j; ++i) {
332 tau[ij] = cmplx(const_r, -const_i) / sigma[i];
340 sigma[j] =
r[j] *
r[j];
345 gamma_prime[j] = cmplx(const_r, -const_i) / sigma[j];
349 valarray<dcomplex> gamma(
m_N_L + 1);
352 gamma[N_L_tmp] = gamma_prime[N_L_tmp];
355 for (
int j = N_L_tmp - 1; j > 0; --j) {
356 c_tmp = cmplx(0.0, 0.0);
358 for (
int i = j + 1; i < N_L_tmp + 1; ++i) {
360 c_tmp += tau[ji] * gamma[i];
363 gamma[j] = gamma_prime[j] - c_tmp;
368 valarray<dcomplex> gamma_double_prime(
m_N_L);
370 for (
int j = 1; j < N_L_tmp; ++j) {
371 c_tmp = cmplx(0.0, 0.0);
373 for (
int i = j + 1; i < N_L_tmp; ++i) {
375 c_tmp += tau[ji] * gamma[i + 1];
378 gamma_double_prime[j] = gamma[j + 1] + c_tmp;
388 mult_c(
v_tmp,
r[N_L_tmp], real(gamma_prime[N_L_tmp]), imag(gamma_prime[N_L_tmp]));
391 mult_c(
v_tmp,
u[N_L_tmp], real(gamma[N_L_tmp]), imag(gamma[N_L_tmp]));
395 for (
int j = 1; j < N_L_tmp; ++j) {
400 mult_c(
v_tmp,
r[j], real(gamma_double_prime[j]), imag(gamma_double_prime[j]));
403 mult_c(
v_tmp,
r[j], real(gamma_prime[j]), imag(gamma_prime[j]));
422 assert(v.
size() == size);
427 for (
int i = 0; i < size; i += 2) {
428 prod_r += v.
cmp(i) * w.
cmp(i) + v.
cmp(i + 1) * w.
cmp(i + 1);
429 prod_i += v.
cmp(i) * w.
cmp(i + 1) - v.
cmp(i + 1) * w.
cmp(i);
440 const double& prod_r,
const double& prod_i)
446 assert(v.
size() == size);
449 for (
int i = 0; i < size; i += 2) {
450 vr = prod_r * w.
cmp(i) - prod_i * w.
cmp(i + 1);
451 vi = prod_r * w.
cmp(i + 1) + prod_i * w.
cmp(i);