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,
18 struct greater_or_equal {
19 static bool check(
const char*
function,
24 VectorView<const T_low> low_vec(low);
25 for (
size_t n = 0; n <
length(low); n++) {
26 if (!(y >= low_vec[n])) {
27 std::stringstream msg;
28 msg <<
", but must be greater than or equal to ";
30 std::string msg_str(msg.str());
32 "is ", msg_str.c_str());
39 template <
typename T_y,
41 struct greater_or_equal<T_y, T_low, true> {
42 static bool check(
const char*
function,
48 VectorView<const T_low> low_vec(low);
49 for (
size_t n = 0; n <
length(y); n++) {
50 if (!(
get(y, n) >= low_vec[n])) {
51 std::stringstream msg;
52 msg <<
", but must be greater than or equal to ";
54 std::string msg_str(msg.str());
56 "is ", msg_str.c_str());
83 template <
typename T_y,
typename T_low>
88 return greater_or_equal<T_y, T_low, is_vector_like<T_y>::value>
89 ::check(
function, name, y, low);
bool check_greater_or_equal(const char *function, const char *name, const T_y &y, const T_low &low)
Return true if y is greater or equal than low.
size_t length(const std::vector< T > &x)
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)
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.