1
1
#ifndef STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
2
2
#define STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
3
3
4
- #include < kinsol/kinsol.h>
5
- #include < cvodes/cvodes.h>
6
4
#include < stan/math/prim/meta.hpp>
7
5
#include < stan/math/prim/err/domain_error.hpp>
6
+ #include < kinsol/kinsol.h>
7
+ #include < cvodes/cvodes.h>
8
8
9
9
namespace stan {
10
10
namespace math {
@@ -196,18 +196,16 @@ inline void cvodes_check(int flag, const char* func_name) {
196
196
197
197
/* *
198
198
* 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
202
200
* until it's fixed we cannot use it to extract flag error string.
203
201
*
204
202
* @param flag Error flag
205
203
* @param func_name calling function name
206
204
* @throw <code>std::runtime_error</code> if the flag is negative.
207
205
*/
208
206
inline void kinsol_check (int flag, const char * func_name) {
209
- std::ostringstream ss;
210
207
if (flag < 0 ) {
208
+ std::ostringstream ss;
211
209
ss << " algebra_solver failed with error flag " << flag << " ." ;
212
210
throw std::runtime_error (ss.str ());
213
211
}
@@ -221,10 +219,10 @@ inline void kinsol_check(int flag, const char* func_name) {
221
219
*
222
220
* @param flag Error flag
223
221
* @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.
225
223
* @throw <code>std::runtime_error</code> if the flag is negative.
226
224
* @throw <code>std::domain_error</code> if the flag indicates max
227
- * number of steps is exceeded..
225
+ * number of steps is exceeded.
228
226
*/
229
227
inline void kinsol_check (int flag, const char * func_name,
230
228
long int max_num_steps) { // NOLINT(runtime/int)
0 commit comments