1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP
22 template <
typename T_y,
typename T_low,
typename T_high,
25 static bool 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());
48 template <
typename T_y,
typename T_low,
typename T_high>
49 struct bounded<T_y, T_low, T_high, true> {
50 static bool check(
const char*
function,
60 for (
size_t n = 0; n <
length(y); n++) {
61 if (!(low_vec[n] <=
get(y, n) &&
get(y, n) <= high_vec[n])) {
62 std::stringstream msg;
63 msg <<
", but must be in the interval ";
64 msg <<
"[" << low_vec[n] <<
", " << high_vec[n] <<
"]";
65 std::string msg_str(msg.str());
67 "is ", msg_str.c_str());
94 template <
typename T_y,
typename T_low,
typename T_high>
102 ::check(
function, name, y, low, high);
Template metaprogram indicates whether a type is vector_like.
size_t length(const std::vector< T > &x)
bool check_bounded(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
Return true if the value is between the low and high values, inclusively.
static bool check(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
static bool check(const char *function, const char *name, const T_y &y, const T_low &low, const T_high &high)
void domain_error_vec(const char *function, const char *name, const T &y, const size_t i, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
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.
VectorView is a template expression that is constructed with a container or scalar, which it then allows to be used as an array using operator[].