12 #ifndef AFILED_HAS_SUB
13 template<
typename AFIELD>
21 #ifndef AFILED_HAS_ADD
22 template<
typename AFIELD>
31 template<
typename AFIELD>
35 template<
typename AFIELD>
40 int nin = m_fopr->field_nin();
41 int nvol = m_fopr->field_nvol();
42 int nex = m_fopr->field_nex();
44 m_r.reset(nin, nvol, nex);
45 m_p.reset(nin, nvol, nex);
49 m_sap_minres->set_parameters(m_min_res_iter, 0.0);
57 template<
typename AFIELD>
66 template<
typename AFIELD>
69 const string str_vlevel = params.
get_string(
"verbose_level");
78 err += params.
fetch_int(
"maximum_number_of_iteration", Niter);
79 err += params.
fetch_int(
"maximum_number_of_restart", Nrestart);
80 err += params.
fetch_double(
"convergence_criterion_squared", Stop_cond);
83 vout.
crucial(m_vl,
"Error at %s: input parameter not found.\n",
88 int Niter2 = Niter * Nrestart;
89 set_parameters(Niter2, Stop_cond);
94 template<
typename AFIELD>
101 m_Stop_cond = Stop_cond;
102 std::string prec =
"double";
103 if (
sizeof(
real_t) == 4) prec =
"float";
107 vout.
general(m_vl,
" Precision: %s\n", prec.c_str());
114 template<
typename AFIELD>
119 vout.
detailed(m_vl,
"asolver_SAP: solve, started in %s\n", __func__);
135 for (
int iter = 0; iter < m_Niter; ++iter) {
137 m_sap_minres->solve(m_p, m_r, nconv, diff0, eo);
142 vout.
general(m_vl,
" after minres: |m_p|^2 = %e\n", p2);
146 m_fopr->mult(m_p, x);
150 m_sap_minres->solve(m_r, m_p, nconv, diff0, eo);
153 double r2 =
norm2(m_r);
154 vout.
general(m_vl,
" after minres: |m_r|^2 = %e\n", r2);
159 m_fopr->mult(m_r, x);
164 double r2 =
norm2(m_r);
165 double x2 =
norm2(x);
166 vout.
general(m_vl,
"iter = %d, r2 = %e, x2 = %e\n", iter, r2, x2);
185 template<
typename AFIELD>
188 int Nin = m_fopr->field_nin();
189 int Nvol = m_fopr->field_nvol();
190 int Nex = m_fopr->field_nex();
193 double flop_minres = m_sap_minres->flop_count();
194 double flop_mult = m_fopr->flop_count();
195 double flop_sub = 2.0 * Nin * Nvol * NPE;
197 = m_Nconv * (2 * flop_minres + 2 * flop_mult + 2 * flop_sub);