21 if (Base::initIteration(rhs,x))
25 m_mat->apply(x,m_tmp);
30 m_p.setZero(m_mat->cols(), 1);
31 m_v.setZero(m_mat->cols(), 1);
37 m_error = m_res.norm() / m_rhs_norm;
39 return m_error < m_tol;
47 m_rho = m_r0.col(0).dot(m_res.col(0));
49 if (
math::abs(m_rho) < m_restartThereshold * m_r0.col(0).dot(m_r0.col(0)) )
51 gsInfo <<
"Residual almost orthogonal, restart with new r0 \n";
53 m_rho = m_r0.col(0).dot(m_r0.col(0));
56 T beta = (m_rho/rho_old)*(m_alpha/m_w);
57 m_p = m_res + beta*(m_p - m_w * m_v);
60 m_precond->apply(m_p, m_y);
62 m_mat->apply(m_y, m_v);
63 m_alpha = m_rho/(m_r0.col(0).dot(m_v.col(0)));
65 m_s.noalias() = m_res - m_alpha * m_v;
67 m_precond->apply(m_s, m_z);
70 m_mat->apply(m_z, m_t);
72 if (m_t.col(0).dot(m_t.col(0)) > 0)
73 m_w = m_t.col(0).dot(m_s.col(0))/m_t.col(0).dot(m_t.col(0));
78 x.noalias() += m_alpha * m_y + m_w * m_z;
79 m_res.noalias() -= m_alpha * m_v + m_w * m_t;
81 m_error = m_res.norm() / m_rhs_norm;
82 return m_error < m_tol;
bool step(VectorType &x)
Perform one step, requires initIteration.
Definition: gsBiCgStab.hpp:44
bool initIteration(const VectorType &rhs, VectorType &x)
Init the iteration.
Definition: gsBiCgStab.hpp:18
#define gsInfo
Definition: gsDebug.h:43
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4486