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

◆ algebra_solver()

template<typename F , typename T1 , typename T2 , require_all_eigen_vector_t< T1, T2 > * = nullptr>
Eigen::Matrix< value_type_t< T2 >, Eigen::Dynamic, 1 > stan::math::algebra_solver ( const F &  f,
const T1 &  x,
const T2 &  y,
const std::vector< double > &  dat,
const std::vector< int > &  dat_int,
std::ostream *  msgs = nullptr,
const double  relative_tolerance = 1e-10,
const double  function_tolerance = 1e-6,
const int64_t  max_num_steps = 1e+3 
)

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 Powell's dogleg solver.

The user can also specify the relative tolerance (xtol in Eigen's code), the function tolerance, and the maximum number of steps (maxfev in Eigen's code).

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

Template Parameters
Ftype of equation system function
T1type of elements in the x vector
T2type of elements in the y vector
Parameters
[in]fFunctor that evaluates the system of equations.
[in]xVector of starting values (initial guess).
[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]relative_tolerancedetermines the convergence criteria for the solution.
[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.
Precondition
f returns finite values when passed any value of x and the given y, dat, and dat_int.
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 relative_tolerance 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>boost::math::evaluation_error</code>(which is a subclass of std::domain_error) if solver exceeds max_num_steps.
<code>boost::math::evaluation_error</code>(which is a subclass of std::domain_error) if the norm of the solution exceeds the function tolerance.

Definition at line 251 of file solve_powell.hpp.