G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsGradientMethod.hpp
Go to the documentation of this file.
1 
14 namespace gismo
15 {
16 
17 template<class T>
20 {
21  if (Base::initIteration(rhs,x))
22  return true;
23 
24  m_mat->apply(x,m_tmp);
25  m_res = rhs - m_tmp;
26 
27  m_error = m_res.norm() / m_rhs_norm;
28  return m_error < m_tol;
29 
30 }
31 
32 template<class T>
34 {
35  m_precond->apply(m_res,m_update);
36  m_mat->apply(m_update,m_tmp);
37 
38  T step_size;
39  if (m_adapt_step_size)
40  step_size = m_tmp.col(0).dot(m_res.col(0)) / m_tmp.col(0).dot(m_tmp.col(0));
41  else
42  step_size = m_step_size;
43 
44  x += step_size * m_update;
45  m_res -= step_size * m_tmp;
46  m_error = m_res.norm() / m_rhs_norm;
47  return m_error < m_tol;
48 }
49 
50 
51 } // end namespace gismo
bool step(VectorType &x)
Perform one step, requires initIteration.
Definition: gsGradientMethod.hpp:33
bool initIteration(const VectorType &rhs, VectorType &x)
Init the iteration.
Definition: gsGradientMethod.hpp:18