Automatic Differentiation
 
Loading...
Searching...
No Matches
check_flag_sundials.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_FLAG_SUNDIALS_HPP
3
6#include <kinsol/kinsol.h>
7#include <cvodes/cvodes.h>
8#include <idas/idas.h>
9#include <arkode/arkode.h>
10#include <array>
11
12namespace stan {
13namespace math {
14
15#define CHECK_CVODES_CALL(call) cvodes_check(call, #call)
16#define CHECK_IDAS_CALL(call) idas_check(call, #call)
17#define CHECK_KINSOL_CALL(call) kinsol_check(call, #call)
18#define CHECK_ARKODE_CALL(call) arkode_check(call, #call)
19
30inline std::array<std::string, 2> cvodes_flag_msg(int flag) {
31 switch (flag) {
32 case CV_TOO_MUCH_WORK:
33 return {"CV_TOO_MUCH_WORK",
34 "The solver took mxstep internal steps but could not reach tout"};
35 case CV_TOO_MUCH_ACC:
36 return {"CV_TOO_MUCH_ACC",
37 "The solver could not satisfy the accuracy demanded by the user "
38 "for some internal step"};
39 case CV_ERR_FAILURE:
40 return {"CV_ERR_FAILURE",
41 "Error test failures occurred too many times during one internal "
42 "time step or minimum step size was reached"};
43 case CV_CONV_FAILURE:
44 return {"CV_CONV_FAILURE",
45 "Convergence test failures occurred too many times during one "
46 "internal time step or minimum step size was reached"};
47 case CV_LINIT_FAIL:
48 return {"CV_LINIT_FAIL",
49 "The linear solver's initialization function failed"};
50 case CV_LSETUP_FAIL:
51 return {"CV_LSETUP_FAIL",
52 "The linear solver's setup function failed in an "
53 "unrecoverable manner"};
54 case CV_LSOLVE_FAIL:
55 return {"CV_LSOLVE_FAIL",
56 "The linear solver's solve function failed in an "
57 "unrecoverable manner"};
58 case CV_RHSFUNC_FAIL:
59 return {"CV_RHSFUNC_FAIL",
60 "The right-hand side function failed in an unrecoverable manner"};
61 case CV_FIRST_RHSFUNC_ERR:
62 return {"CV_FIRST_RHSFUNC_ERR",
63 "The right-hand side function failed at the first call"};
64 case CV_REPTD_RHSFUNC_ERR:
65 return {"CV_REPTD_RHSFUNC_ERR",
66 "The right-hand side function had repeated recoverable errors"};
67 case CV_UNREC_RHSFUNC_ERR:
68 return {"CV_UNREC_RHSFUNC_ERR",
69 "The right-hand side function had a recoverable error, but no "
70 "recovery is possible"};
71 case CV_RTFUNC_FAIL:
72 return {"CV_RTFUNC_FAIL",
73 "The rootfinding function failed in an unrecoverable manner"};
74 case CV_NLS_INIT_FAIL:
75 return {"CV_NLS_INIT_FAIL", "The nonlinear solver's init routine failed"};
76 case CV_NLS_SETUP_FAIL:
77 return {"CV_NLS_SETUP_FAIL",
78 "The nonlinear solver's setup routine failed"};
79 case CV_CONSTR_FAIL:
80 return {"CV_CONSTR_FAIL",
81 "The inequality constraints were violated and the solver was "
82 "unable to recover"};
83 case CV_MEM_FAIL:
84 return {"CV_MEM_FAIL", "A memory allocation failed"};
85 case CV_MEM_NULL:
86 return {"CV_MEM_NULL", "The cvode_mem argument was NULL"};
87 case CV_ILL_INPUT:
88 return {"CV_ILL_INPUT", "One of the function inputs is illegal"};
89 case CV_NO_MALLOC:
90 return {"CV_NO_MALLOC",
91 "The CVODE memory block was not allocated by a call to "
92 "CVodeMalloc"};
93 case CV_BAD_K:
94 return {"CV_BAD_K",
95 "The derivative order k is larger than the order used"};
96 case CV_BAD_T:
97 return {"CV_BAD_T", "The time t is outside the last step taken"};
98 case CV_BAD_DKY:
99 return {"CV_BAD_DKY", "The output derivative vector is NULL"};
100 case CV_TOO_CLOSE:
101 return {"CV_TOO_CLOSE",
102 "The output and initial times are too close to each other"};
103 case CV_NO_QUAD:
104 return {"CV_NO_QUAD", "Quadrature integration was not activated"};
105 case CV_QRHSFUNC_FAIL:
106 return {"CV_QRHSFUNC_FAIL",
107 "The quadrature right-hand side function failed in an "
108 "unrecoverable manner"};
109 case CV_FIRST_QRHSFUNC_ERR:
110 return {"CV_FIRST_QRHSFUNC_ERR",
111 "The quadrature right-hand side function failed at the first "
112 "call"};
113 case CV_REPTD_QRHSFUNC_ERR:
114 return {"CV_REPTD_QRHSFUNC_ERR",
115 "The quadrature right-hand side function had repeated "
116 "recoverable errors"};
117 case CV_UNREC_QRHSFUNC_ERR:
118 return {"CV_UNREC_QRHSFUNC_ERR",
119 "The quadrature right-hand side function had a recoverable "
120 "error, but no recovery is possible"};
121 case CV_NO_SENS:
122 return {"CV_NO_SENS",
123 "Forward sensitivity integration was not activated"};
124 case CV_SRHSFUNC_FAIL:
125 return {"CV_SRHSFUNC_FAIL",
126 "The sensitivity right-hand side function failed in an "
127 "unrecoverable manner"};
128 case CV_FIRST_SRHSFUNC_ERR:
129 return {"CV_FIRST_SRHSFUNC_ERR",
130 "The sensitivity right-hand side function failed at the first "
131 "call"};
132 case CV_REPTD_SRHSFUNC_ERR:
133 return {"CV_REPTD_SRHSFUNC_ERR",
134 "The sensitivity right-hand side function had repeated "
135 "recoverable errors"};
136 case CV_UNREC_SRHSFUNC_ERR:
137 return {"CV_UNREC_SRHSFUNC_ERR",
138 "The sensitivity right-hand side function had a recoverable "
139 "error, but no recovery is possible"};
140 case CV_BAD_IS:
141 return {"CV_BAD_IS",
142 "The sensitivity index is larger than the number of "
143 "sensitivities computed"};
144 case CV_NO_QUADSENS:
145 return {"CV_NO_QUADSENS",
146 "Forward quadrature sensitivity integration was not activated"};
147 case CV_QSRHSFUNC_FAIL:
148 return {"CV_QSRHSFUNC_FAIL",
149 "The quadrature sensitivity right-hand side function failed in "
150 "an unrecoverable manner"};
151 case CV_FIRST_QSRHSFUNC_ERR:
152 return {"CV_FIRST_QSRHSFUNC_ERR",
153 "The quadrature sensitivity right-hand side function failed at "
154 "the first call"};
155 case CV_REPTD_QSRHSFUNC_ERR:
156 return {"CV_REPTD_QSRHSFUNC_ERR",
157 "The quadrature sensitivity right-hand side function had "
158 "repeated recoverable errors"};
159 case CV_UNREC_QSRHSFUNC_ERR:
160 return {"CV_UNREC_QSRHSFUNC_ERR",
161 "The quadrature sensitivity right-hand side function had a "
162 "recoverable error, but no recovery is possible"};
163 case CV_CONTEXT_ERR:
164 return {"CV_CONTEXT_ERR", "The SUNContext object is NULL"};
165 case CV_NO_ADJ:
166 return {"CV_NO_ADJ", "Adjoint module was not initialized"};
167 case CV_NO_FWD:
168 return {"CV_NO_FWD", "The forward integration was not yet performed"};
169 case CV_NO_BCK:
170 return {"CV_NO_BCK", "No backward problem was specified"};
171 case CV_BAD_TB0:
172 return {"CV_BAD_TB0",
173 "The final time for the adjoint problem is outside the "
174 "interval over which the forward problem was solved"};
175 case CV_REIFWD_FAIL:
176 return {"CV_REIFWD_FAIL",
177 "Reinitialization of the forward problem failed at the first "
178 "checkpoint"};
179 case CV_FWD_FAIL:
180 return {"CV_FWD_FAIL",
181 "An error occurred during the integration of the forward "
182 "problem"};
183 case CV_GETY_BADT:
184 return {"CV_GETY_BADT", "Wrong time in interpolation function"};
185 }
186 return {"CV_UNKNOWN_ERROR", "Unrecognized CVODES error flag"};
187}
188
197inline void cvodes_check(int flag, const char* func_name) {
198 if (flag < 0) {
199 std::ostringstream ss;
200 ss << func_name << " failed with error flag " << flag << ": \n"
201 << cvodes_flag_msg(flag).at(1) << ".";
202 throw std::domain_error(ss.str());
203 }
204}
205
214inline std::array<std::string, 2> idas_flag_msg(int flag) {
215 switch (flag) {
216 case IDA_TOO_MUCH_WORK:
217 return {
218 "IDA_TOO_MUCH_WORK",
219 "The solver took mxstep internal steps but could not reach tout."};
220 case IDA_TOO_MUCH_ACC:
221 return {"IDA_TOO_MUCH_ACC",
222 "The solver could not satisfy the accuracy demanded by the user "
223 "for some internal step."};
224 case IDA_ERR_FAIL:
225 return {"IDA_ERR_FAIL",
226 "Error test failures occurred too many times during one internal "
227 "time step or minimum step size was reached."};
228 case IDA_CONV_FAIL:
229 return {"IDA_CONV_FAIL",
230 "Convergence test failures occurred too many times during one "
231 "internal time step or minimum step size was reached."};
232 case IDA_LINIT_FAIL:
233 return {"IDA_LINIT_FAIL",
234 "The linear solver's initialization function failed."};
235 case IDA_LSETUP_FAIL:
236 return {"IDA_LSETUP_FAIL",
237 "The linear solver's setup function failed in an unrecoverable "
238 "manner."};
239 case IDA_LSOLVE_FAIL:
240 return {"IDA_LSOLVE_FAIL",
241 "The linear solver's solve function failed in an unrecoverable "
242 "manner."};
243 case IDA_RES_FAIL:
244 return {"IDA_RES_FAIL",
245 "The user-provided residual function failed in an unrecoverable "
246 "manner."};
247 case IDA_REP_RES_ERR:
248 return {"IDA_REP_RES_ERR",
249 "The user-provided residual function repeatedly returned a "
250 "recoverable error flag, but the solver was unable to recover."};
251 case IDA_RTFUNC_FAIL:
252 return {"IDA_RTFUNC_FAIL",
253 "The rootfinding function failed in an unrecoverable manner."};
254 case IDA_CONSTR_FAIL:
255 return {"IDA_CONSTR_FAIL",
256 "The inequality constraints were violated and the solver was "
257 "unable to recover."};
258 case IDA_FIRST_RES_FAIL:
259 return {"IDA_FIRST_RES_FAIL",
260 "The user-provided residual function failed recoverably on the "
261 "first call."};
262 case IDA_LINESEARCH_FAIL:
263 return {"IDA_LINESEARCH_FAIL", "The line search failed."};
264 case IDA_NO_RECOVERY:
265 return {"IDA_NO_RECOVERY",
266 "The residual function, linear solver setup function, or "
267 "linear solver solve function had a recoverable failure, but "
268 "IDACalcIC could not recover."};
269 case IDA_NLS_INIT_FAIL:
270 return {"IDA_NLS_INIT_FAIL",
271 "The nonlinear solver's init routine failed."};
272 case IDA_NLS_SETUP_FAIL:
273 return {"IDA_NLS_SETUP_FAIL",
274 "The nonlinear solver's setup routine failed."};
275 case IDA_MEM_NULL:
276 return {"IDA_MEM_NULL", "The ida_mem argument was NULL."};
277 case IDA_MEM_FAIL:
278 return {"IDA_MEM_FAIL", "A memory allocation failed."};
279 case IDA_ILL_INPUT:
280 return {"IDA_ILL_INPUT", "One of the function inputs is illegal."};
281 case IDA_NO_MALLOC:
282 return {"IDA_NO_MALLOC",
283 "The IDAS memory was not allocated by a call to IDAInit."};
284 case IDA_BAD_EWT:
285 return {"IDA_BAD_EWT", "Zero value of some error weight component."};
286 case IDA_BAD_K:
287 return {"IDA_BAD_K", "The k-th derivative is not available."};
288 case IDA_BAD_T:
289 return {"IDA_BAD_T", "The time t is outside the last step taken."};
290 case IDA_BAD_DKY:
291 return {"IDA_BAD_DKY",
292 "The vector argument where derivative should be stored is NULL."};
293 case IDA_VECTOROP_ERR:
294 return {"IDA_VECTOROP_ERR", "A vector operation failed."};
295 case IDA_CONTEXT_ERR:
296 return {"IDA_CONTEXT_ERR",
297 "An error occurred in the SUNDIALS context object."};
298 case IDA_NO_QUAD:
299 return {"IDA_NO_QUAD", "Quadratures were not initialized."};
300 case IDA_QRHS_FAIL:
301 return {"IDA_QRHS_FAIL",
302 "The user-provided right-hand side function for quadratures "
303 "failed in an unrecoverable manner."};
304 case IDA_FIRST_QRHS_ERR:
305 return {"IDA_FIRST_QRHS_ERR",
306 "The user-provided right-hand side function for quadratures "
307 "failed in an unrecoverable manner on the first call."};
308 case IDA_REP_QRHS_ERR:
309 return {"IDA_REP_QRHS_ERR",
310 "The user-provided right-hand side repeatedly returned a "
311 "recoverable error flag, but the solver was unable to recover."};
312 case IDA_NO_SENS:
313 return {"IDA_NO_SENS", "Sensitivities were not initialized."};
314 case IDA_SRES_FAIL:
315 return {"IDA_SRES_FAIL",
316 "The user-provided sensitivity residual function failed in an "
317 "unrecoverable manner."};
318 case IDA_REP_SRES_ERR:
319 return {"IDA_REP_SRES_ERR",
320 "The user-provided sensitivity residual function repeatedly "
321 "returned a recoverable error flag, but the solver was "
322 "unable to recover."};
323 case IDA_BAD_IS:
324 return {"IDA_BAD_IS", "The sensitivity identifier is not valid."};
325 case IDA_NO_QUADSENS:
326 return {"IDA_NO_QUADSENS",
327 "Sensitivity-dependent quadratures were not initialized."};
328 case IDA_QSRHS_FAIL:
329 return {"IDA_QSRHS_FAIL",
330 "The user-provided sensitivity-dependent quadrature right-hand "
331 "side function failed in an unrecoverable manner."};
332 case IDA_FIRST_QSRHS_ERR:
333 return {"IDA_FIRST_QSRHS_ERR",
334 "The user-provided sensitivity-dependent quadrature right-hand "
335 "side function failed in an unrecoverable manner on the first "
336 "call."};
337 case IDA_REP_QSRHS_ERR:
338 return {"IDA_REP_QSRHS_ERR",
339 "The user-provided sensitivity-dependent quadrature right-hand "
340 "side repeatedly returned a recoverable error flag, but the "
341 "solver was unable to recover."};
342 case IDA_NO_ADJ:
343 return {"IDA_NO_ADJ",
344 "The combined forward-backward problem has not been "
345 "initialized."};
346 case IDA_NO_FWD:
347 return {"IDA_NO_FWD", "IDASolveF has not been previously called."};
348 case IDA_NO_BCK:
349 return {"IDA_NO_BCK", "No backward problem was specified."};
350 case IDA_BAD_TB0:
351 return {"IDA_BAD_TB0",
352 "The desired output for backward problem is outside the "
353 "interval over which the forward problem was solved."};
354 case IDA_REIFWD_FAIL:
355 return {"IDA_REIFWD_FAIL",
356 "No checkpoint is available for this hot start."};
357 case IDA_FWD_FAIL:
358 return {"IDA_FWD_FAIL",
359 "IDASolveB failed because IDASolve was unable to store data "
360 "between two consecutive checkpoints."};
361 case IDA_GETY_BADT:
362 return {"IDA_GETY_BADT", "Wrong time in interpolation function."};
363 }
364 return {"IDA_UNKNOWN_ERROR", "Unrecognized IDAS error flag."};
365}
366
367inline void idas_check(int flag, const char* func_name) {
368 if (flag < 0) {
369 std::ostringstream ss;
370 ss << func_name << " failed with error flag " << flag << ": \n"
371 << idas_flag_msg(flag).at(1);
372 throw std::domain_error(ss.str());
373 }
374}
375
386inline std::array<std::string, 2> arkode_flag_msg(int flag) {
387 switch (flag) {
388 case ARK_TOO_MUCH_WORK:
389 return {"ARK_TOO_MUCH_WORK",
390 "The solver took mxstep internal steps but could not reach "
391 "tout"};
392 case ARK_TOO_MUCH_ACC:
393 return {"ARK_TOO_MUCH_ACC",
394 "The solver could not satisfy the accuracy demanded by the user "
395 "for some internal step"};
396 case ARK_ERR_FAILURE:
397 return {"ARK_ERR_FAILURE",
398 "Error test failures occurred too many times during one "
399 "internal time step, or the minimum step size was reached"};
400 case ARK_CONV_FAILURE:
401 return {"ARK_CONV_FAILURE",
402 "Convergence test failures occurred too many times during one "
403 "internal time step, or the minimum step size was reached"};
404 case ARK_LINIT_FAIL:
405 return {"ARK_LINIT_FAIL",
406 "The linear solver's initialization function failed"};
407 case ARK_LSETUP_FAIL:
408 return {"ARK_LSETUP_FAIL",
409 "The linear solver's setup function failed in an "
410 "unrecoverable manner"};
411 case ARK_LSOLVE_FAIL:
412 return {"ARK_LSOLVE_FAIL",
413 "The linear solver's solve function failed in an "
414 "unrecoverable manner"};
415 case ARK_RHSFUNC_FAIL:
416 return {"ARK_RHSFUNC_FAIL",
417 "The right-hand side function failed in an unrecoverable "
418 "manner"};
419 case ARK_FIRST_RHSFUNC_ERR:
420 return {"ARK_FIRST_RHSFUNC_ERR",
421 "The right-hand side function failed at the first call"};
422 case ARK_REPTD_RHSFUNC_ERR:
423 return {"ARK_REPTD_RHSFUNC_ERR",
424 "The right-hand side function had repeated recoverable errors"};
425 case ARK_UNREC_RHSFUNC_ERR:
426 return {"ARK_UNREC_RHSFUNC_ERR",
427 "The right-hand side function had a recoverable error, but no "
428 "recovery is possible"};
429 case ARK_RTFUNC_FAIL:
430 return {"ARK_RTFUNC_FAIL",
431 "The rootfinding function failed in an unrecoverable manner"};
432 case ARK_LFREE_FAIL:
433 return {"ARK_LFREE_FAIL",
434 "The linear solver's memory deallocation function failed"};
435 case ARK_MASSINIT_FAIL:
436 return {"ARK_MASSINIT_FAIL",
437 "The mass matrix linear solver's initialization function "
438 "failed"};
439 case ARK_MASSSETUP_FAIL:
440 return {"ARK_MASSSETUP_FAIL",
441 "The mass matrix linear solver's setup function failed in an "
442 "unrecoverable manner"};
443 case ARK_MASSSOLVE_FAIL:
444 return {"ARK_MASSSOLVE_FAIL",
445 "The mass matrix linear solver's solve function failed in an "
446 "unrecoverable manner"};
447 case ARK_MASSFREE_FAIL:
448 return {"ARK_MASSFREE_FAIL",
449 "The mass matrix linear solver's memory deallocation "
450 "function failed"};
451 case ARK_MASSMULT_FAIL:
452 return {"ARK_MASSMULT_FAIL",
453 "The mass matrix-vector product function failed"};
454 case ARK_CONSTR_FAIL:
455 return {"ARK_CONSTR_FAIL",
456 "The inequality constraint test failed repeatedly or failed "
457 "with the minimum step size"};
458 case ARK_MEM_FAIL:
459 return {"ARK_MEM_FAIL", "A memory allocation failed"};
460 case ARK_MEM_NULL:
461 return {"ARK_MEM_NULL", "The arkode_mem argument was NULL"};
462 case ARK_ILL_INPUT:
463 return {"ARK_ILL_INPUT", "One of the function inputs is illegal"};
464 case ARK_NO_MALLOC:
465 return {"ARK_NO_MALLOC",
466 "The ARKODE memory block was not allocated by a call to "
467 "ARKStepCreate, ERKStepCreate, or MRIStepCreate"};
468 case ARK_BAD_K:
469 return {"ARK_BAD_K", "The derivative order k is larger than allowed"};
470 case ARK_BAD_T:
471 return {"ARK_BAD_T", "The time t is outside the last step taken"};
472 case ARK_BAD_DKY:
473 return {"ARK_BAD_DKY", "The output derivative vector is NULL"};
474 case ARK_TOO_CLOSE:
475 return {"ARK_TOO_CLOSE",
476 "The output and initial times are too close to each other"};
477 case ARK_VECTOROP_ERR:
478 return {"ARK_VECTOROP_ERR",
479 "An error occurred when calling an N_Vector routine"};
480 case ARK_NLS_INIT_FAIL:
481 return {"ARK_NLS_INIT_FAIL",
482 "An error occurred when initializing a SUNNonlinSol module"};
483 case ARK_NLS_SETUP_FAIL:
484 return {"ARK_NLS_SETUP_FAIL",
485 "A non-recoverable error occurred when setting up a "
486 "SUNNonlinSol module"};
487 case ARK_NLS_SETUP_RECVR:
488 return {"ARK_NLS_SETUP_RECVR",
489 "A recoverable error occurred when setting up a SUNNonlinSol "
490 "module"};
491 case ARK_NLS_OP_ERR:
492 return {"ARK_NLS_OP_ERR",
493 "An error occurred when calling a set/get routine in a "
494 "SUNNonlinSol module"};
495 case ARK_INNERSTEP_ATTACH_ERR:
496 return {"ARK_INNERSTEP_ATTACH_ERR",
497 "An error occurred when attaching the inner stepper module"};
498 case ARK_INNERSTEP_FAIL:
499 return {"ARK_INNERSTEP_FAIL",
500 "An error occurred in the inner stepper module"};
501 case ARK_OUTERTOINNER_FAIL:
502 return {"ARK_OUTERTOINNER_FAIL",
503 "An error occurred in the MRIStep pre inner integrator "
504 "function"};
505 case ARK_INNERTOOUTER_FAIL:
506 return {"ARK_INNERTOOUTER_FAIL",
507 "An error occurred in the MRIStep post inner integrator "
508 "function"};
509 case ARK_POSTPROCESS_STEP_FAIL:
510 return {"ARK_POSTPROCESS_STEP_FAIL",
511 "An error occurred in a step postprocessing function"};
512 case ARK_POSTPROCESS_STAGE_FAIL:
513 return {"ARK_POSTPROCESS_STAGE_FAIL",
514 "An error occurred in a stage postprocessing function"};
515 case ARK_USER_PREDICT_FAIL:
516 return {"ARK_USER_PREDICT_FAIL",
517 "An error occurred in a user predictor function"};
518 case ARK_INTERP_FAIL:
519 return {"ARK_INTERP_FAIL",
520 "An error occurred in the ARKODE polynomial interpolation "
521 "module"};
522 case ARK_INVALID_TABLE:
523 return {"ARK_INVALID_TABLE",
524 "An invalid Butcher or MRI table was encountered"};
525 case ARK_CONTEXT_ERR:
526 return {"ARK_CONTEXT_ERR",
527 "An error occurred with the SUNDIALS context object"};
528 case ARK_UNRECOGNIZED_ERROR:
529 return {"ARK_UNRECOGNIZED_ERROR", "An unknown error was encountered"};
530 }
531 return {"ARK_UNKNOWN_ERROR", "Unrecognized ARKODE error flag"};
532}
533
534inline void arkode_check(int flag, const char* func_name) {
535 if (flag < 0) {
536 std::ostringstream ss;
537 ss << func_name << " failed with error flag " << flag << ": \n"
538 << arkode_flag_msg(flag).at(1) << ".";
539 throw std::domain_error(ss.str());
540 }
541}
542
552inline void kinsol_check(int flag, const char* func_name) {
553 if (flag < 0) {
554 std::ostringstream ss;
555 ss << "algebra_solver failed with error flag " << flag << ".";
556 throw std::runtime_error(ss.str());
557 }
558}
559
573inline void kinsol_check(int flag, const char* func_name,
574 long int max_num_steps) { // NOLINT(runtime/int)
575 std::ostringstream ss;
576 if (flag == -6) {
577 domain_error("algebra_solver", "maximum number of iterations",
578 max_num_steps, "(", ") was exceeded in the solve.");
579 } else if (flag == -11) {
580 ss << "The linear solver’s setup function failed "
581 << "in an unrecoverable manner.";
582 throw std::runtime_error(ss.str());
583 } else if (flag < 0) {
584 ss << "algebra_solver failed with error flag " << flag << ".";
585 throw std::runtime_error(ss.str());
586 }
587}
588
589} // namespace math
590} // namespace stan
591#endif
std::array< std::string, 2 > idas_flag_msg(int flag)
Map idas error flag to actually error msg.
std::array< std::string, 2 > cvodes_flag_msg(int flag)
Map cvodes error flag to actually error msg.
void arkode_check(int flag, const char *func_name)
void idas_check(int flag, const char *func_name)
void cvodes_check(int flag, const char *func_name)
Throws a std::domain_error exception when a Sundial function fails (i.e.
std::array< std::string, 2 > arkode_flag_msg(int flag)
Map ARKODE error flag to an error msg.
void kinsol_check(int flag, const char *func_name)
Throws an exception message when the functions in KINSOL fails.
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...