Stan Math Library
4.9.0
Automatic Differentiation
|
Eigen::Matrix< T2, -1, 1 > stan::math::algebra_solver_fp | ( | const F & | f, |
const Eigen::Matrix< T1, -1, 1 > & | x, | ||
const Eigen::Matrix< T2, -1, 1 > & | y, | ||
const std::vector< double > & | x_r, | ||
const std::vector< int > & | x_i, | ||
const std::vector< T_u > & | u_scale, | ||
const std::vector< T_f > & | f_scale, | ||
std::ostream * | msgs = nullptr , |
||
double | f_tol = 1e-8 , |
||
int | max_num_steps = 200 |
||
) |
Return a fixed pointer to the specified system of algebraic equations of form.
x = F(x; theta)
given an initial guess x, and parameters theta and data. Use the KINSOL solver from the SUNDIALS suite.
The user can also specify the scaling controls, the function tolerance, and the maximum number of steps.
F | type of equation system function. |
T | type of initial guess vector. The final solution type doesn't depend on initial guess type, but we allow initial guess to be either data or param. |
T_u | type of scaling vector for unknowns. We allow it to be var because scaling could be parameter dependent. Internally these params are converted to data because scaling is applied. |
T_f | type of scaling vector for residual. We allow it to be var because scaling could be parameter dependent. Internally these params are converted to data because scaling is applied. |
[in] | f | Functor that evaluated the system of equations. |
[in] | x | Vector of starting values. |
[in] | y | Parameter vector for the equation system. The function is overloaded to treat y as a vector of doubles or of a a template type T. |
[in] | x_r | Continuous data vector for the equation system. |
[in] | x_i | Integer data vector for the equation system. |
[in,out] | msgs | The print stream for warning messages. |
[in] | u_scale | diagonal scaling matrix elements Du such that Du*x has all components roughly the same magnitude when x is close to a solution. (ref. KINSOL user guide chap.2 sec. "Scaling") |
[in] | f_scale | diagonal scaling matrix elements such that Df*(x-f(x)) has all components roughly the same magnitude when x is not too close to a solution. (ref. KINSOL user guide chap.2 sec. "Scaling") |
[in] | f_tol | Function-norm stopping tolerance. |
[in] | max_num_steps | maximum number of function evaluations. |
<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>boost::math::evaluation_error</code> | (which is a subclass of std::runtime_error ) if solver exceeds max_num_steps. |
Definition at line 365 of file algebra_solver_fp.hpp.