11#ifndef STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
22#define STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
33
4- #include < kinsol/kinsol.h>
5- #include < cvodes/cvodes.h>
64#include < stan/math/prim/meta.hpp>
75#include < stan/math/prim/err/domain_error.hpp>
6+ #include < kinsol/kinsol.h>
7+ #include < cvodes/cvodes.h>
88
99namespace stan {
1010namespace math {
@@ -196,18 +196,16 @@ inline void cvodes_check(int flag, const char* func_name) {
196196
197197/* *
198198 * Throws an exception message when the functions in KINSOL
199- * fails. When the exception is caused
200- * by a tuning parameter the user controls, gives a specific
201- * error. "KINGetReturnFlagName()" from sundials has a mem leak bug so
199+ * fails. "KINGetReturnFlagName()" from SUNDIALS has a mem leak bug so
202200 * until it's fixed we cannot use it to extract flag error string.
203201 *
204202 * @param flag Error flag
205203 * @param func_name calling function name
206204 * @throw <code>std::runtime_error</code> if the flag is negative.
207205 */
208206inline void kinsol_check (int flag, const char * func_name) {
209- std::ostringstream ss;
210207 if (flag < 0 ) {
208+ std::ostringstream ss;
211209 ss << " algebra_solver failed with error flag " << flag << " ." ;
212210 throw std::runtime_error (ss.str ());
213211 }
@@ -221,10 +219,10 @@ inline void kinsol_check(int flag, const char* func_name) {
221219 *
222220 * @param flag Error flag
223221 * @param func_name calling function name
224- * @param max_num_steps max number of nonlinear iters
222+ * @param max_num_steps max number of nonlinear iterations.
225223 * @throw <code>std::runtime_error</code> if the flag is negative.
226224 * @throw <code>std::domain_error</code> if the flag indicates max
227- * number of steps is exceeded..
225+ * number of steps is exceeded.
228226 */
229227inline void kinsol_check (int flag, const char * func_name,
230228 long int max_num_steps) { // NOLINT(runtime/int)
0 commit comments