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

◆ algebra_solver_fp()

template<typename F , typename T1 , typename T2 , typename T_u , typename T_f >
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.

Template Parameters
Ftype of equation system function.
Ttype 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_utype 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_ftype 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.
Parameters
[in]fFunctor that evaluated the system of equations.
[in]xVector of starting values.
[in]yParameter 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_rContinuous data vector for the equation system.
[in]x_iInteger data vector for the equation system.
[in,out]msgsThe print stream for warning messages.
[in]u_scalediagonal 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_scalediagonal 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_tolFunction-norm stopping tolerance.
[in]max_num_stepsmaximum number of function evaluations.
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>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.