1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP 2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP 23 template <
typename T_y,
typename T_low,
typename T_high,
bool y_is_vec>
25 static void check(
const char*
function,
34 for (
size_t n = 0; n <
max_size(low, high); n++) {
35 if (!(low_vec[n] <= y && y <= high_vec[n])) {
36 std::stringstream msg;
37 msg <<
", but must be in the interval ";
38 msg <<
"[" << low_vec[n] <<
", " << high_vec[n] <<
"]";
39 std::string msg_str(msg.str());
41 "is ", msg_str.c_str());
47 template <
typename T_y,
typename T_low,
typename T_high>
48 struct bounded<T_y, T_low, T_high, true> {
49 static void check(
const char*
function,
59 for (
size_t n = 0; n <
length(y); n++) {
60 if (!(low_vec[n] <=
get(y, n) &&
get(y, n) <= high_vec[n])) {
61 std::stringstream msg;
62 msg <<
", but must be in the interval ";
63 msg <<
"[" << low_vec[n] <<
", " << high_vec[n] <<
"]";
64 std::string msg_str(msg.str());
66 "is ", msg_str.c_str());
90 template <
typename T_y,
typename T_low,
typename T_high>
97 ::check(
function, name, y, low, high);
void check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Check if the value is between the low and high values, inclusively.
scalar_seq_view provides a uniform sequence-like wrapper around either a scalar or a sequence of scal...
size_t length(const std::vector< T > &x)
void domain_error_vec(const char *function, const char *name, const T &y, size_t i, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
static void check(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
static void check(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
T get(const std::vector< T > &x, size_t n)
size_t max_size(const T1 &x1, const T2 &x2)
void domain_error(const char *function, const char *name, const T &y, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.