G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsGradientMethod.hpp
Go to the documentation of this file.
1
14namespace gismo
15{
16
17template<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
32template<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
The G+Smo namespace, containing all definitions for the library.