1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_LESS_OR_EQUAL_HPP 2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_LESS_OR_EQUAL_HPP 16 template <
typename T_y,
typename T_high,
bool is_vec>
17 struct less_or_equal {
18 static void check(
const char*
function,
23 scalar_seq_view<T_high> high_vec(high);
24 for (
size_t n = 0; n <
length(high); n++) {
25 if (!(y <= high_vec[n])) {
26 std::stringstream msg;
27 msg <<
", but must be less than or equal to ";
29 std::string msg_str(msg.str());
31 "is ", msg_str.c_str());
37 template <
typename T_y,
typename T_high>
38 struct less_or_equal<T_y, T_high, true> {
39 static void check(
const char*
function,
44 scalar_seq_view<T_high> high_vec(high);
45 for (
size_t n = 0; n <
length(y); n++) {
47 std::stringstream msg;
48 msg <<
", but must be less than or equal to ";
50 std::string msg_str(msg.str());
52 "is ", msg_str.c_str());
77 template <
typename T_y,
typename T_high>
82 less_or_equal<T_y, T_high, is_vector_like<T_y>::value>
83 ::check(
function, name, y, high);
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high)
Check if y is less or equal to high.
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.
T get(const std::vector< T > &x, size_t n)
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.