numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::roots::newton_raphson< Function > Class Template Reference

Class of Newton-Raphson method. More...

#include <num_collect/roots/newton_raphson.h>

+ Inheritance diagram for num_collect::roots::newton_raphson< Function >:
+ Collaboration diagram for num_collect::roots::newton_raphson< Function >:

Public Types

using base_type
 Type of base class.
 
using jacobian_solver_type
 Type of solvers of Jacobian matrices.
 
using jacobian_type = typename function_type::jacobian_type
 Type of Jacobian matrices.
 
using scalar_type = typename variable_type::Scalar
 Type of scalars in variables.
 
using this_type = newton_raphson<Function>
 Type of this object.
 
- Public Types inherited from num_collect::roots::function_root_finder_base< newton_raphson< Function >, Function >
using function_type
 Type of function of equation.
 
using variable_type
 Type of variables.
 

Public Member Functions

 newton_raphson (const function_type &function=function_type())
 Constructor.
 
 newton_raphson (const function_type &function=function_type())
 Constructor.
 
void configure_iteration_logger (logging::iterations::iteration_logger< this_type > &iteration_logger) const
 Configure an iteration logger.
 
void configure_iteration_logger (logging::iterations::iteration_logger< this_type > &iteration_logger) const
 Configure an iteration logger.
 
auto evaluations () const noexcept -> index_type
 Get the number of function evaluations.
 
auto evaluations () const noexcept -> index_type
 Get the number of function evaluations.
 
void init (const variable_type &variable)
 Initialize.
 
void init (const variable_type &variable)
 Initialize.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
void iterate ()
 Iterate the algorithm once.
 
void iterate ()
 Iterate the algorithm once.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto iterations () const noexcept -> index_type
 Get the number of iterations.
 
auto jacobian () const -> std::invoke_result_t< decltype(&function_type::jacobian), const function_type >
 Get Jacobian matrix.
 
auto jacobian () const -> std::invoke_result_t< decltype(&function_type::jacobian), const function_type >
 Get Jacobian matrix.
 
auto last_change () const noexcept -> scalar_type
 Get the last change of the variable.
 
auto last_change () const noexcept -> variable_type
 Get the last change of the variable.
 
auto max_iterations (index_type val) -> this_type &
 Set maximum number of iterations.
 
auto max_iterations (index_type val) -> this_type &
 Set maximum number of iterations.
 
auto tol_last_change (const scalar_type &val) -> this_type &
 Set tolerance of last change of the variable.
 
auto tol_last_change (const variable_type &val) -> this_type &
 Set tolerance of last change of the variable.
 
auto tol_value_norm (const scalar_type &val) -> this_type &
 Set tolerance of the norm of function value.
 
auto tol_value_norm (const variable_type &val) -> this_type &
 Set tolerance of the norm of function value.
 
auto value () const -> std::invoke_result_t< decltype(&function_type::value), const function_type >
 Get current value.
 
auto value () const -> std::invoke_result_t< decltype(&function_type::value), const function_type >
 Get current value.
 
auto value_norm () const noexcept -> scalar_type
 Get the norm of function value.
 
auto value_norm () const noexcept -> variable_type
 Get the norm of function value.
 
auto variable () const -> const variable_type &
 Get current variable.
 
auto variable () const -> const variable_type &
 Get current variable.
 
- Public Member Functions inherited from num_collect::roots::function_root_finder_base< newton_raphson< Function >, Function >
 function_root_finder_base (logging::log_tag_view tag, const function_type &function=function_type())
 Constructor.
 
auto function () -> function_type &
 Get the function of equation.
 
auto function () const -> const function_type &
 Get the function of equation.
 
- Public Member Functions inherited from num_collect::base::iterative_solver_base< newton_raphson< Function > >
 iterative_solver_base (logging::log_tag_view tag)
 Constructor.
 
 iterative_solver_base (logging::log_tag_view tag)
 Constructor.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
auto is_stop_criteria_satisfied () const -> bool
 Determine if stopping criteria of the algorithm are satisfied.
 
void iterate ()
 Iterate the algorithm once.
 
void iterate ()
 Iterate the algorithm once.
 
void solve ()
 Solve the problem.
 
void solve ()
 Solve the problem.
 
- Public Member Functions inherited from num_collect::logging::logging_mixin
 logging_mixin (log_tag_view tag)
 Constructor.
 
template<typename Child >
void configure_child_algorithm_logger_if_exists (Child &child)
 Configure a logger of a child algorithm if exists.
 
auto logger () const noexcept -> const num_collect::logging::logger &
 Access to the logger.
 
auto logger () noexcept -> num_collect::logging::logger &
 Access to the logger.
 
- Public Member Functions inherited from num_collect::logging::iterations::iteration_logger_mixin< newton_raphson< Function > >
 iteration_logger_mixin ()=default
 Constructor.
 
void configure_iteration_logger (num_collect::logging::iterations::iteration_logger< newton_raphson< Function > > &iteration_logger) const
 Configure an iteration logger.
 
auto initialize_iteration_logger () -> num_collect::logging::iterations::iteration_logger< newton_raphson< Function > > &
 Get the iteration logger.
 

Private Attributes

variable_type change_ {}
 Change.
 
index_type evaluations_ {}
 Number of function evaluations.
 
index_type iterations_ {}
 Number of iterations.
 
jacobian_solver_type jacobian_solver_ {}
 Solver of Jacobian matrices.
 
variable_type last_change_ {}
 Last change of the variable.
 
scalar_type last_change_ {}
 Last change of the variable.
 
index_type max_iterations_ {default_max_iterations}
 Maximum iterations.
 
variable_type tol_last_change_ {default_tol_last_change}
 Threshold of last change of the variable.
 
scalar_type tol_last_change_ {default_tol_last_change}
 Threshold of last change of the variable.
 
variable_type tol_value_norm_ {default_tol_value_norm}
 Threshold of the norm of function value.
 
scalar_type tol_value_norm_ {default_tol_value_norm}
 Threshold of the norm of function value.
 
variable_type value_norm_ {}
 Norm of function value.
 
scalar_type value_norm_ {}
 Norm of function value.
 
variable_type variable_ {}
 Variable.
 

Static Private Attributes

static constexpr index_type default_max_iterations = 1000
 Default maximum iterations.
 
static constexpr auto default_tol_last_change
 Default tolerance of last change of the variable.
 
static constexpr auto default_tol_value_norm
 Default tolerance of the norm of function value.
 

Additional Inherited Members

- Protected Member Functions inherited from num_collect::base::iterative_solver_base< newton_raphson< Function > >
auto derived () const noexcept -> const newton_raphson< Function > &
 Access derived object.
 
auto derived () const noexcept -> const newton_raphson< Function > &
 Access derived object.
 
auto derived () noexcept -> newton_raphson< Function > &
 Access derived object.
 
auto derived () noexcept -> newton_raphson< Function > &
 Access derived object.
 

Detailed Description

template<concepts::multi_variate_differentiable_function Function>
class num_collect::roots::newton_raphson< Function >

Class of Newton-Raphson method.

This version is used when variable type is a floating-point number type.

Template Parameters
FunctionType of the function of equation.

This version is used when variable type is Eigen's vector.

Template Parameters
FunctionType of the function of equation.

Definition at line 296 of file newton_raphson.h.

Member Typedef Documentation

◆ base_type

template<concepts::multi_variate_differentiable_function Function>
typedef function_root_finder_base< newton_raphson< Function >, Function > num_collect::roots::newton_raphson< Function >::base_type
Initial value:

Type of base class.

Definition at line 68 of file newton_raphson.h.

◆ jacobian_solver_type

template<concepts::multi_variate_differentiable_function Function>
using num_collect::roots::newton_raphson< Function >::jacobian_solver_type
Initial value:
Eigen::PartialPivLU<typename Function::jacobian_type>

Type of solvers of Jacobian matrices.

Definition at line 316 of file newton_raphson.h.

◆ jacobian_type

template<concepts::multi_variate_differentiable_function Function>
using num_collect::roots::newton_raphson< Function >::jacobian_type = typename function_type::jacobian_type

Type of Jacobian matrices.

Definition at line 313 of file newton_raphson.h.

◆ scalar_type

template<concepts::multi_variate_differentiable_function Function>
using num_collect::roots::newton_raphson< Function >::scalar_type = typename variable_type::Scalar

Type of scalars in variables.

Definition at line 310 of file newton_raphson.h.

◆ this_type

template<concepts::multi_variate_differentiable_function Function>
typedef newton_raphson< Function > num_collect::roots::newton_raphson< Function >::this_type = newton_raphson<Function>

Type of this object.

Definition at line 65 of file newton_raphson.h.

Constructor & Destructor Documentation

◆ newton_raphson() [1/2]

template<concepts::multi_variate_differentiable_function Function>
num_collect::roots::newton_raphson< Function >::newton_raphson ( const function_type & function = function_type())
inlineexplicit

Constructor.

Parameters
[in]functionFunction of equation.

Definition at line 82 of file newton_raphson.h.

◆ newton_raphson() [2/2]

template<concepts::multi_variate_differentiable_function Function>
num_collect::roots::newton_raphson< Function >::newton_raphson ( const function_type & function = function_type())
inlineexplicit

Constructor.

Parameters
[in]functionFunction of equation.

Definition at line 324 of file newton_raphson.h.

Member Function Documentation

◆ configure_iteration_logger() [1/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::configure_iteration_logger ( logging::iterations::iteration_logger< this_type > & iteration_logger) const
inline

Configure an iteration logger.

Parameters
[in]iteration_loggerIteration logger.

Definition at line 123 of file newton_raphson.h.

◆ configure_iteration_logger() [2/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::configure_iteration_logger ( logging::iterations::iteration_logger< this_type > & iteration_logger) const
inline

Configure an iteration logger.

Parameters
[in]iteration_loggerIteration logger.

Definition at line 364 of file newton_raphson.h.

◆ evaluations() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::evaluations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of function evaluations.

Returns
Number of function evaluations.

Definition at line 183 of file newton_raphson.h.

◆ evaluations() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::evaluations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of function evaluations.

Returns
Number of function evaluations.

Definition at line 424 of file newton_raphson.h.

◆ init() [1/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::init ( const variable_type & variable)
inline

Initialize.

Parameters
[in]variableInitial variable.

Definition at line 90 of file newton_raphson.h.

◆ init() [2/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::init ( const variable_type & variable)
inline

Initialize.

Parameters
[in]variableInitial variable.

Definition at line 332 of file newton_raphson.h.

◆ is_stop_criteria_satisfied() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::is_stop_criteria_satisfied ( ) const -> bool
inlinenodiscard

Determine if stopping criteria of the algorithm are satisfied.

Returns
If stopping criteria of the algorithm are satisfied.

Definition at line 116 of file newton_raphson.h.

◆ is_stop_criteria_satisfied() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::is_stop_criteria_satisfied ( ) const -> bool
inlinenodiscard

Determine if stopping criteria of the algorithm are satisfied.

Returns
If stopping criteria of the algorithm are satisfied.

Definition at line 357 of file newton_raphson.h.

◆ iterate() [1/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::iterate ( )
inline

Iterate the algorithm once.

Warning
Any required initializations (with init functions) are assumed to have been done.

Definition at line 103 of file newton_raphson.h.

◆ iterate() [2/2]

template<concepts::multi_variate_differentiable_function Function>
void num_collect::roots::newton_raphson< Function >::iterate ( )
inline

Iterate the algorithm once.

Warning
Any required initializations (with init functions) are assumed to have been done.

Definition at line 344 of file newton_raphson.h.

◆ iterations() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 174 of file newton_raphson.h.

◆ iterations() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::iterations ( ) const -> index_type
inlinenodiscardnoexcept

Get the number of iterations.

Returns
Number of iterations.

Definition at line 415 of file newton_raphson.h.

◆ jacobian() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::jacobian ( ) const -> std::invoke_result_t<decltype(&function_type::jacobian), const function_type>
inlinenodiscard

Get Jacobian matrix.

Returns
Jacobian matrix.

Definition at line 163 of file newton_raphson.h.

◆ jacobian() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::jacobian ( ) const -> std::invoke_result_t<decltype(&function_type::jacobian), const function_type>
inlinenodiscard

Get Jacobian matrix.

Returns
Jacobian matrix.

Definition at line 404 of file newton_raphson.h.

◆ last_change() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::last_change ( ) const -> scalar_type
inlinenodiscardnoexcept

Get the last change of the variable.

Returns
Last change of the variable.

Definition at line 433 of file newton_raphson.h.

◆ last_change() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::last_change ( ) const -> variable_type
inlinenodiscardnoexcept

Get the last change of the variable.

Returns
Last change of the variable.

Definition at line 192 of file newton_raphson.h.

◆ max_iterations() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::max_iterations ( index_type val) -> this_type&
inline

Set maximum number of iterations.

Parameters
[in]valValue.
Returns
This.

Definition at line 211 of file newton_raphson.h.

◆ max_iterations() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::max_iterations ( index_type val) -> this_type&
inline

Set maximum number of iterations.

Parameters
[in]valValue.
Returns
This.

Definition at line 452 of file newton_raphson.h.

◆ tol_last_change() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::tol_last_change ( const scalar_type & val) -> this_type&
inline

Set tolerance of last change of the variable.

Parameters
[in]valValue.
Returns
This.

Definition at line 465 of file newton_raphson.h.

◆ tol_last_change() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::tol_last_change ( const variable_type & val) -> this_type&
inline

Set tolerance of last change of the variable.

Parameters
[in]valValue.
Returns
This.

Definition at line 224 of file newton_raphson.h.

◆ tol_value_norm() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::tol_value_norm ( const scalar_type & val) -> this_type&
inline

Set tolerance of the norm of function value.

Parameters
[in]valValue.
Returns
This.

Definition at line 480 of file newton_raphson.h.

◆ tol_value_norm() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::tol_value_norm ( const variable_type & val) -> this_type&
inline

Set tolerance of the norm of function value.

Parameters
[in]valValue.
Returns
This.

Definition at line 239 of file newton_raphson.h.

◆ value() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::value ( ) const -> std::invoke_result_t<decltype(&function_type::value), const function_type>
inlinenodiscard

Get current value.

Returns
Current value.

Definition at line 152 of file newton_raphson.h.

◆ value() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::value ( ) const -> std::invoke_result_t<decltype(&function_type::value), const function_type>
inlinenodiscard

Get current value.

Returns
Current value.

Definition at line 393 of file newton_raphson.h.

◆ value_norm() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::value_norm ( ) const -> scalar_type
inlinenodiscardnoexcept

Get the norm of function value.

Returns
Norm of function value.

Definition at line 442 of file newton_raphson.h.

◆ value_norm() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::value_norm ( ) const -> variable_type
inlinenodiscardnoexcept

Get the norm of function value.

Returns
Norm of function value.

Definition at line 201 of file newton_raphson.h.

◆ variable() [1/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::variable ( ) const -> const variable_type&
inlinenodiscard

Get current variable.

Returns
Current variable.

Definition at line 143 of file newton_raphson.h.

◆ variable() [2/2]

template<concepts::multi_variate_differentiable_function Function>
auto num_collect::roots::newton_raphson< Function >::variable ( ) const -> const variable_type&
inlinenodiscard

Get current variable.

Returns
Current variable.

Definition at line 384 of file newton_raphson.h.

Member Data Documentation

◆ change_

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::change_ {}
private

Change.

Definition at line 253 of file newton_raphson.h.

◆ default_max_iterations

template<concepts::multi_variate_differentiable_function Function>
static constexpr index_type num_collect::roots::newton_raphson< Function >::default_max_iterations = 1000
staticconstexprprivate

Default maximum iterations.

Definition at line 268 of file newton_raphson.h.

◆ default_tol_last_change

template<concepts::multi_variate_differentiable_function Function>
static constexpr auto num_collect::roots::newton_raphson< Function >::default_tol_last_change
staticconstexprprivate
Initial value:

Default tolerance of last change of the variable.

Definition at line 274 of file newton_raphson.h.

◆ default_tol_value_norm

template<concepts::multi_variate_differentiable_function Function>
static constexpr auto num_collect::roots::newton_raphson< Function >::default_tol_value_norm
staticconstexprprivate
Initial value:
=
static_cast<variable_type>(1e-6)

Default tolerance of the norm of function value.

Definition at line 281 of file newton_raphson.h.

◆ evaluations_

template<concepts::multi_variate_differentiable_function Function>
index_type num_collect::roots::newton_raphson< Function >::evaluations_ {}
private

Number of function evaluations.

Definition at line 259 of file newton_raphson.h.

◆ iterations_

template<concepts::multi_variate_differentiable_function Function>
index_type num_collect::roots::newton_raphson< Function >::iterations_ {}
private

Number of iterations.

Definition at line 256 of file newton_raphson.h.

◆ jacobian_solver_

template<concepts::multi_variate_differentiable_function Function>
jacobian_solver_type num_collect::roots::newton_raphson< Function >::jacobian_solver_ {}
private

Solver of Jacobian matrices.

Definition at line 497 of file newton_raphson.h.

◆ last_change_ [1/2]

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::last_change_ {}
private

Last change of the variable.

Definition at line 262 of file newton_raphson.h.

◆ last_change_ [2/2]

template<concepts::multi_variate_differentiable_function Function>
scalar_type num_collect::roots::newton_raphson< Function >::last_change_ {}
private

Last change of the variable.

Definition at line 506 of file newton_raphson.h.

◆ max_iterations_

template<concepts::multi_variate_differentiable_function Function>
index_type num_collect::roots::newton_raphson< Function >::max_iterations_ {default_max_iterations}
private

Maximum iterations.

Definition at line 271 of file newton_raphson.h.

◆ tol_last_change_ [1/2]

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::tol_last_change_ {default_tol_last_change}
private

Threshold of last change of the variable.

Definition at line 278 of file newton_raphson.h.

◆ tol_last_change_ [2/2]

template<concepts::multi_variate_differentiable_function Function>
scalar_type num_collect::roots::newton_raphson< Function >::tol_last_change_ {default_tol_last_change}
private

Threshold of last change of the variable.

Definition at line 522 of file newton_raphson.h.

◆ tol_value_norm_ [1/2]

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::tol_value_norm_ {default_tol_value_norm}
private

Threshold of the norm of function value.

Definition at line 285 of file newton_raphson.h.

◆ tol_value_norm_ [2/2]

template<concepts::multi_variate_differentiable_function Function>
scalar_type num_collect::roots::newton_raphson< Function >::tol_value_norm_ {default_tol_value_norm}
private

Threshold of the norm of function value.

Definition at line 529 of file newton_raphson.h.

◆ value_norm_ [1/2]

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::value_norm_ {}
private

Norm of function value.

Definition at line 265 of file newton_raphson.h.

◆ value_norm_ [2/2]

template<concepts::multi_variate_differentiable_function Function>
scalar_type num_collect::roots::newton_raphson< Function >::value_norm_ {}
private

Norm of function value.

Definition at line 509 of file newton_raphson.h.

◆ variable_

template<concepts::multi_variate_differentiable_function Function>
variable_type num_collect::roots::newton_raphson< Function >::variable_ {}
private

Variable.

Definition at line 250 of file newton_raphson.h.


The documentation for this class was generated from the following file: