30 const Real delta_u_max_factor = 100;
31 Real norm_delta_u_max = delta_u_max_factor*std::max(P.space_norm(
u), Real(1.));
36 if (p_derr) *p_derr <<
"# damped-Newton: n r T lambda wall-time cpu" << std::endl << std::flush;
37 for (Size n = 0;
true; n++) {
38 P.update_derivative (
u);
39 Field Fu = P.residue(
u);
40 Field delta_u = -P.derivative_solve (Fu);
42 if (p_derr) *p_derr << n <<
" " << P.dual_space_norm(Fu) <<
" " << sqrt(2.*Tu)
44 if (2.*Tu <= sqr(tol) || n >= max_iter) {
49 Real slope =
T.slope(P, Fu, delta_u);
54 P,
T, u_old, Tu_old, delta_u, slope, norm_delta_u_max,
u, Fu, Tu,
lambda, p_derr);
60 Field Gu =
T.grad(P,Fu);
61 const Float eps_mach = std::numeric_limits<Float>::epsilon();
64 if (P.space_norm(Gu) > eps_mach*P.dual_space_norm(Fu)) {
65 if (p_derr) *p_derr <<
"# damped-Newton: warning: machine precision reached" << std::endl << std::flush;
68 if (p_derr) *p_derr <<
"# damped-Newton: warning: gradient is zero up to machine precision" << std::endl << std::flush;
int damped_newton(const Problem &P, const Preconditioner &T, Field &u, Real &tol, Size &max_iter, odiststream *p_derr=0)
see the damped_newton page for the full documentation
int newton_backtrack(const Problem &P, const Preconditioner &T, const Field &u_old, Float Tu_old, Field &delta_u, Real slope, Real norm_delta_u_max, Field &u, Field &Fu, Real &Tu, Real &lambda, odiststream *p_derr=0)