1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_GREATER_OR_EQUAL_HPP 2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_GREATER_OR_EQUAL_HPP 15 template <
typename T_y,
typename T_low,
bool is_vec>
16 struct greater_or_equal {
17 static void check(
const char*
function,
22 scalar_seq_view<T_low> low_vec(low);
23 for (
size_t n = 0; n <
length(low); n++) {
24 if (!(y >= low_vec[n])) {
25 std::stringstream msg;
26 msg <<
", but must be greater than or equal to ";
28 std::string msg_str(msg.str());
30 "is ", msg_str.c_str());
36 template <
typename T_y,
typename T_low>
37 struct greater_or_equal<T_y, T_low, true> {
38 static void check(
const char*
function,
44 scalar_seq_view<T_low> low_vec(low);
45 for (
size_t n = 0; n <
length(y); n++) {
46 if (!(
get(y, n) >= low_vec[n])) {
47 std::stringstream msg;
48 msg <<
", but must be greater than or equal to ";
50 std::string msg_str(msg.str());
52 "is ", msg_str.c_str());
77 template <
typename T_y,
typename T_low>
82 greater_or_equal<T_y, T_low, is_vector_like<T_y>::value>
83 ::check(
function, name, y, low);
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.
void check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low)
Check if y is greater or equal than low.
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.