13#ifndef OPTIMIST_ROOTFINDER_NEWTON_HH
14#define OPTIMIST_ROOTFINDER_NEWTON_HH
40 template <
typename Real, Integer N>
90 Real residuals, step_norm;
91 Vector x_old, x_new, function_old, function_new, step_old, step_new;
108 this->
m_lu.compute(jacobian_old);
110 "Optimist::RootFinder::Newton::solve(...): singular Jacobian detected.");
111 step_old = -this->
m_lu.solve(function_old);
114 residuals = function_old.norm();
115 step_norm = step_old.norm();
117 if (residuals < tolerance_residuals || step_norm < tolerance_step_norm) {
125 damped = this->
damp(function, x_old, function_old, step_old, x_new, function_new, step_new);
127 "Optimist::RootFinder::Newton::solve(...): damping failed.");
130 x_new = x_old + step_old;
136 function_old = function_new;
#define OPTIMIST_ASSERT_WARNING(COND, MSG)
Definition Optimist.hh:60
#define OPTIMIST_BASIC_CONSTANTS(Real)
Definition Optimist.hh:70
#define OPTIMIST_ASSERT(COND, MSG)
Definition Optimist.hh:43
Newton()
Definition Newton.hh:63
static constexpr bool requires_function
Definition Newton.hh:44
static constexpr bool requires_first_derivative
Definition Newton.hh:45
bool solve_impl(FunctionWrapper function, JacobianWrapper jacobian, Vector const &x_ini, Vector &x_sol)
Definition Newton.hh:80
typename RootFinder< Real, N, Newton< Real, N >, true >::Vector Vector
Definition Newton.hh:50
typename RootFinder< Real, N, Newton< Real, N >, true >::JacobianWrapper JacobianWrapper
Definition Newton.hh:53
std::string name_impl() const
Definition Newton.hh:69
typename RootFinder< Real, N, Newton< Real, N >, true >::FunctionWrapper FunctionWrapper
Definition Newton.hh:52
Eigen::FullPivLU< Matrix > m_lu
Definition Newton.hh:57
static constexpr bool requires_second_derivative
Definition Newton.hh:46
typename RootFinder< Real, N, Newton< Real, N >, true >::Matrix Matrix
Definition Newton.hh:51
bool solve(FunctionWrapper function, Vector const &x_ini, Vector &x_sol)
Definition RootFinder.hh:163
RootFinder()
Definition RootFinder.hh:82
void evaluate_jacobian(JacobianWrapper jacobian, const Vector &x, Matrix &out)
Definition RootFinder.hh:139
bool m_damped
Definition SolverBase.hh:95
void info(Real residuals, std::string const ¬es="-")
Definition SolverBase.hh:860
Integer m_iterations
Definition SolverBase.hh:86
Integer m_max_iterations
Definition SolverBase.hh:87
void header()
Definition SolverBase.hh:806
void reset()
Definition SolverBase.hh:700
bool m_verbose
Definition SolverBase.hh:94
bool m_converged
Definition SolverBase.hh:100
bool damp(FunctionWrapper function, InputType const &x_old, InputType const &function_old, InputType const &step_old, InputType &x_new, InputType &function_new, InputType &step_new)
Definition SolverBase.hh:770
void store_trace(const InputType &x)
Definition SolverBase.hh:757
void bottom()
Definition SolverBase.hh:836
Real m_tolerance
Definition SolverBase.hh:93
void evaluate_function(FunctionWrapper function, const InputType &x, OutputType &out)
Definition SolverBase.hh:717
Namespace for the Optimist library.
Definition Optimist.hh:87
OPTIMIST_DEFAULT_INTEGER_TYPE Integer
The Integer type as used for the API.
Definition Optimist.hh:95