20 Base::initIteration(rhs,x);
26 vPrev.setZero(n,m); vNew.setZero(n,m);
27 wPrev.setZero(n,m); w.setZero(n,m); wNew.setZero(n,m);
28 if (!m_inexact_residual)
29 { AwPrev.setZero(n,m); Aw.setZero(n,m); AwNew.setZero(n,m); }
31 m_mat->apply(x,negResidual);
34 m_error = negResidual.norm() / m_rhs_norm;
39 m_precond->apply(v, z);
42 T ip = z.col(0).dot(v.col(0));
43 GISMO_ASSERT(ip >= T(0),
"gsMinimalResidual::initIteration(...), preconditioner not positive semi-definite");
44 gamma = math::sqrt(ip);
47 sPrev = 0; s = 0; sNew = 0;
48 cPrev = 1; c = 1; cNew = 1;
59 T delta = z.col(0).dot(Az.col(0));
60 vNew = Az - (delta/gamma)*v - (gamma/gammaPrev)*vPrev;
61 m_precond->apply(vNew, zNew);
62 T ip = zNew.col(0).dot(vNew.col(0));
63 GISMO_ASSERT(ip >= T(0),
"gsMinimalResidual::step(...), preconditioner not positive semi-definite");
64 gammaNew = math::sqrt(ip);
65 const T a0 = c*delta - cPrev*s*gamma;
66 const T a1 = math::sqrt(a0*a0 + gammaNew*gammaNew);
67 const T a2 = s*delta + cPrev*c*gamma;
68 const T a3 = sPrev*gamma;
71 wNew = (z - a3*wPrev - a2*w)/a1;
72 if (!m_inexact_residual)
73 AwNew = (Az - a3*AwPrev - a2*Aw)/a1;
75 if (!m_inexact_residual)
76 negResidual += cNew*eta*AwNew;
78 if (m_inexact_residual)
81 m_error = negResidual.norm() / m_rhs_norm;
90 vPrev.swap(v); v.swap(vNew);
91 wPrev.swap(w); w.swap(wNew);
92 if (!m_inexact_residual)
93 { AwPrev.swap(Aw); Aw.swap(AwNew); }
95 gammaPrev = gamma; gamma = gammaNew;
106 vPrev.clear(); v.clear(); vNew.clear();
107 wPrev.clear(); w.clear(); wNew.clear();
108 AwPrev.clear(); Aw.clear(); AwNew.clear();
109 zNew.clear(); z.clear(); Az.clear();
void finalizeIteration(VectorType &x)
Some post-processing might be required.
Definition: gsMinimalResidual.hpp:102
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
bool initIteration(const VectorType &rhs, VectorType &x)
Init the iteration.
Definition: gsMinimalResidual.hpp:18
bool step(VectorType &x)
Perform one step, requires initIteration.
Definition: gsMinimalResidual.hpp:54
EIGEN_STRONG_INLINE abs_expr< E > abs(const E &u)
Absolute value.
Definition: gsExpressions.h:4488