1 #ifndef STAN__MATH__ERROR_HANDLING_CHECK_NONNEGATIVE_HPP
2 #define STAN__MATH__ERROR_HANDLING_CHECK_NONNEGATIVE_HPP
6 #include <boost/type_traits/is_unsigned.hpp>
15 template <
typename T_y,
typename T_result,
bool is_vec>
17 static bool check(
const char*
function,
23 if (!boost::is_unsigned<T_y>::value && !(y >= 0))
25 " is %1%, but must be >= 0!",
"",
31 template <
typename T_y,
typename T_result>
32 struct nonnegative<T_y, T_result, true> {
33 static bool check(
const char*
function,
38 for (
size_t n = 0; n <
length(y); n++) {
39 if (!boost::is_unsigned<
typename value_type<T_y>::type>::value
42 " is %1%, but must be >= 0!",
"",
51 template <
typename T_y,
typename T_result>
56 return nonnegative<T_y,T_result,is_vector_like<T_y>::value>
57 ::check(
function, y, name, result);
bool dom_err(const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
bool dom_err_vec(const size_t i, const char *function, const T &y, const char *name, const char *error_msg, const T_msg error_msg2, T_result *result)
bool check_nonnegative(const char *function, const T_y &y, const char *name, T_result *result)
T get(const T &x, size_t n)