Automatic Differentiation
 
Loading...
Searching...
No Matches

◆ algebra_solver_newton()

template<typename F , typename T1 , typename T2 , require_all_eigen_vector_t< T1, T2 > * = nullptr>
Eigen::Matrix< scalar_type_t< T2 >, Eigen::Dynamic, 1 > stan::math::algebra_solver_newton ( const F &  f,
const T1 &  x,
const T2 &  y,
const std::vector< double > &  dat,
const std::vector< int > &  dat_int,
std::ostream *const  msgs = nullptr,
const double  scaling_step_size = 1e-3,
const double  function_tolerance = 1e-6,
const long int  max_num_steps = 200 
)

Return the solution to the specified system of algebraic equations given an initial guess, and parameters and data, which get passed into the algebraic system.

Use the KINSOL solver from the SUNDIALS suite.

The user can also specify the scaled step size, the function tolerance, and the maximum number of steps.

Signature to maintain backward compatibility, will be removed in the future.

Template Parameters
Ftype of equation system function.
Ttype of initial guess vector.
Parameters
[in]fFunctor that evaluated the system of equations.
[in]xVector of starting values.
[in]yParameter vector for the equation system.
[in]datContinuous data vector for the equation system.
[in]dat_intInteger data vector for the equation system.
[in,out]msgsThe print stream for warning messages.
[in]scaling_step_sizeScaled-step stopping tolerance. If a Newton step is smaller than the scaling step tolerance, the code breaks, assuming the solver is no longer making significant progress (i.e. is stuck)
[in]function_tolerancedetermines whether roots are acceptable.
[in]max_num_stepsmaximum number of function evaluations.
Returns
theta Vector of solutions to the system of equations.
Exceptions
<code>std::invalid_argument</code>if x has size zero.
<code>std::invalid_argument</code>if x has non-finite elements.
<code>std::invalid_argument</code>if y has non-finite elements.
<code>std::invalid_argument</code>if dat has non-finite elements.
<code>std::invalid_argument</code>if dat_int has non-finite elements.
<code>std::invalid_argument</code>if scaled_step_size is strictly negative.
<code>std::invalid_argument</code>if function_tolerance is strictly negative.
<code>std::invalid_argument</code>if max_num_steps is not positive.
<code>std::domain_errorif solver exceeds max_num_steps.

Definition at line 295 of file solve_newton.hpp.