Automatic Differentiation
 
Loading...
Searching...
No Matches
check_range.hpp
Go to the documentation of this file.
1#ifndef STAN_MATH_PRIM_ERR_CHECK_RANGE_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_RANGE_HPP
3
6#include <sstream>
7#include <string>
8
9namespace stan {
10namespace math {
11
24inline void check_range(const char* function, const char* name, int max,
25 int index, int nested_level, const char* error_msg) {
27 if (!((index >= stan::error_index::value)
28 && (index < max + stan::error_index::value))) {
29 [&]() STAN_COLD_PATH {
30 std::stringstream msg;
31 msg << "; index position = " << nested_level;
32 std::string msg_str(msg.str());
33 out_of_range(function, max, index, msg_str.c_str(), error_msg);
34 }();
35 }
36}
37
49inline void check_range(const char* function, const char* name, int max,
50 int index, const char* error_msg) {
52 if (!((index >= stan::error_index::value)
53 && (index < max + stan::error_index::value))) {
54 [&]() STAN_COLD_PATH { out_of_range(function, max, index, error_msg); }();
55 }
56}
57
68inline void check_range(const char* function, const char* name, int max,
69 int index) {
71 if (!((index >= stan::error_index::value)
72 && (index < max + stan::error_index::value))) {
73 [&]() STAN_COLD_PATH { out_of_range(function, max, index); }();
74 }
75}
76
77} // namespace math
78} // namespace stan
79#endif
#define STAN_COLD_PATH
#define STAN_NO_RANGE_CHECKS_RETURN
Turns all range and size checks into no-ops.
auto max(T1 x, T2 y)
Returns the maximum value of the two specified scalar arguments.
Definition max.hpp:25
void out_of_range(const char *function, int max, int index, const char *msg1="", const char *msg2="")
Throw an out_of_range exception with a consistently formatted message.
void check_range(const char *function, const char *name, int max, int index, int nested_level, const char *error_msg)
Check if specified index is within range.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...