1 #ifndef __STAN__MATH__ERROR_HANDLING__CHECK_BOUNDED_HPP__
2 #define __STAN__MATH__ERROR_HANDLING__CHECK_BOUNDED_HPP__
12 template <
typename T_y,
19 static bool check(
const char*
function,
28 VectorView<const T_low> low_vec(low);
29 VectorView<const T_high> high_vec(high);
30 for (
size_t n = 0; n <
max_size(low, high); n++) {
31 if (!(low_vec[n] <= y && y <= high_vec[n]))
32 return dom_err(
function,y,name,
" is %1%, but must be between ",
33 std::pair<
typename scalar_type<T_low>::type,
34 typename scalar_type<T_high>::type>(low_vec[n],
42 template <
typename T_y,
47 struct bounded<T_y, T_low, T_high, T_result, Policy, true> {
48 static bool check(
const char*
function,
57 VectorView<const T_low> low_vec(low);
58 VectorView<const T_high> high_vec(high);
59 for (
size_t n = 0; n <
length(y); n++) {
60 if (!(low_vec[n] <=
get(y,n) &&
get(y,n) <= high_vec[n]))
62 " is %1%, but must be between ",
63 std::pair<
typename scalar_type<T_low>::type,
64 typename scalar_type<T_high>::type>(low_vec[n],
72 template <
typename T_y,
typename T_low,
typename T_high,
typename T_result,
class Policy>
80 return bounded<T_y,T_low,T_high,T_result,Policy,
82 ::check(
function,y,low,high,name,result,Policy());
84 template <
typename T_y,
typename T_low,
typename T_high,
typename T_result>
93 template <
typename T_y,
typename T_low,
typename T_high>
99 return check_bounded<T_y,T_low,T_high,typename scalar_type<T_y>::type *>