50template <concepts::differentiable_function Function>
60template <concepts::single_variate_differentiable_function Function>
75 std::is_same_v<variable_type, typename function_type::jacobian_type>);
92 last_change_ = std::numeric_limits<variable_type>::infinity();
126 iteration_logger.template append<index_type>(
128 iteration_logger.template append<index_type>(
130 iteration_logger.template append<variable_type>(
132 iteration_logger.template append<variable_type>(
136 using base_type::function;
213 "Maximum number of iterations must be a positive integer.");
227 "Tolerance of last change of the variable must be a "
228 "non-negative value.");
242 "Tolerance of the norm of function value must be a "
243 "non-negative value.");
295template <concepts::multi_variate_differentiable_function Function>
296class newton_raphson<Function>
297 :
public function_root_finder_base<newton_raphson<Function>, Function> {
317 Eigen::PartialPivLU<typename Function::jacobian_type>;
334 last_change_ = std::numeric_limits<scalar_type>::infinity();
367 iteration_logger.template append<index_type>(
369 iteration_logger.template append<index_type>(
371 iteration_logger.template append<scalar_type>(
373 iteration_logger.template append<scalar_type>(
377 using base_type::function;
454 "Maximum number of iterations must be a positive integer.");
468 "Tolerance of last change of the variable must be a "
469 "non-negative value.");
483 "Tolerance of the norm of function value must be a "
484 "non-negative value.");
491 variable_type variable_{};
494 variable_type change_{};
512 static constexpr index_type default_max_iterations = 1000;
515 index_type max_iterations_{default_max_iterations};
518 static constexpr auto default_tol_last_change =
519 static_cast<scalar_type
>(1e-6);
525 static constexpr auto default_tol_value_norm =
526 static_cast<scalar_type
>(1e-6);
Class to write logs of iterations.
Class of tags of logs without memory management.
auto logger() const noexcept -> const num_collect::logging::logger &
Access to the logger.
function_root_finder_base(logging::log_tag_view tag, const function_type &function=function_type())
typename function_type::variable_type variable_type
function_root_finder_base< newton_raphson< Function >, Function > base_type
Type of base class.
auto function() -> function_type &
Get the function of equation.
jacobian_solver_type jacobian_solver_
Solver of Jacobian matrices.
variable_type last_change_
Last change of the variable.
void iterate()
Iterate the algorithm once.
auto jacobian() const -> std::invoke_result_t< decltype(&function_type::jacobian), const function_type >
Get Jacobian matrix.
void init(const variable_type &variable)
Initialize.
newton_raphson(const function_type &function=function_type())
Constructor.
static constexpr auto default_tol_last_change
Default tolerance of last change of the variable.
auto variable() const -> const variable_type &
Get current variable.
variable_type variable_
Variable.
typename variable_type::Scalar scalar_type
Type of scalars in variables.
index_type max_iterations_
Maximum iterations.
auto iterations() const noexcept -> index_type
Get the number of iterations.
auto tol_last_change(const variable_type &val) -> this_type &
Set tolerance of last change of the variable.
auto last_change() const noexcept -> variable_type
Get the last change of the variable.
index_type evaluations_
Number of function evaluations.
auto evaluations() const noexcept -> index_type
Get the number of function evaluations.
auto value_norm() const noexcept -> scalar_type
Get the norm of function value.
auto tol_value_norm(const variable_type &val) -> this_type &
Set tolerance of the norm of function value.
index_type iterations_
Number of iterations.
variable_type tol_last_change_
Threshold of last change of the variable.
static constexpr index_type default_max_iterations
Default maximum iterations.
void configure_iteration_logger(logging::iterations::iteration_logger< this_type > &iteration_logger) const
Configure an iteration logger.
auto last_change() const noexcept -> scalar_type
Get the last change of the variable.
static constexpr auto default_tol_value_norm
Default tolerance of the norm of function value.
variable_type tol_value_norm_
Threshold of the norm of function value.
auto value_norm() const noexcept -> variable_type
Get the norm of function value.
auto max_iterations(index_type val) -> this_type &
Set maximum number of iterations.
auto is_stop_criteria_satisfied() const -> bool
Determine if stopping criteria of the algorithm are satisfied.
newton_raphson< Function > this_type
Type of this object.
Eigen::PartialPivLU< typename Function::jacobian_type > jacobian_solver_type
Type of solvers of Jacobian matrices.
variable_type value_norm_
Norm of function value.
auto tol_value_norm(const scalar_type &val) -> this_type &
Set tolerance of the norm of function value.
variable_type change_
Change.
typename function_type::jacobian_type jacobian_type
Type of Jacobian matrices.
auto value() const -> std::invoke_result_t< decltype(&function_type::value), const function_type >
Get current value.
auto tol_last_change(const scalar_type &val) -> this_type &
Set tolerance of last change of the variable.
Class of Newton-Raphson method.
Definition of differentiable_function concept.
Definition of exceptions.
Definition of function_root_finder_base class.
Definition of index_type type.
Definition of iteration_logger class.
Definition of log_tag_view class.
Definition of macros for logging.
Definition of multi_variate_differentiable_function concept.
std::ptrdiff_t index_type
Type of indices in this library.
Namespace of root-finding algorithms.
constexpr auto newton_raphson_tag
Tag of newton_raphson.
Definition of NUM_COLLECT_PRECONDITION macro.
#define NUM_COLLECT_PRECONDITION(CONDITION,...)
Check whether a precondition is satisfied and throw an exception if not.
Definition of single_variate_differentiable_function concept.