1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP 2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_BOUNDED_HPP 19 template <
typename T_y,
typename T_low,
typename T_high,
bool y_is_vec>
21 static void check(
const char*
function,
const char* name,
const T_y& y,
22 const T_low& low,
const T_high& high) {
26 if (!(low_vec[n] <= y && y <= high_vec[n])) {
27 std::stringstream msg;
28 msg <<
", but must be in the interval ";
29 msg <<
"[" << low_vec[n] <<
", " << high_vec[n] <<
"]";
30 std::string msg_str(msg.str());
37 template <
typename T_y,
typename T_low,
typename T_high>
38 struct bounded<T_y, T_low, T_high, true> {
39 static void check(
const char*
function,
const char* name,
const T_y& y,
40 const T_low& low,
const T_high& high) {
45 std::stringstream msg;
46 msg <<
", but must be in the interval ";
47 msg <<
"[" << low_vec[n] <<
", " << high_vec[n] <<
"]";
48 std::string msg_str(msg.str());
69 template <
typename T_y,
typename T_low,
typename T_high>
70 inline void check_bounded(
const char*
function,
const char* name,
const T_y& y,
71 const T_low& low,
const T_high& high) {
73 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)
Returns the length of the provided std::vector.
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)
Returns the n-th element of the provided std::vector.
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.