1#ifndef STAN_MATH_PRIM_ERR_CHECK_LESS_OR_EQUAL_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_LESS_OR_EQUAL_HPP
34template <
typename T_y,
typename T_high,
35 require_all_stan_scalar_t<T_y, T_high>* =
nullptr,
typename... Idxs>
37 const T_y& y,
const T_high& high,
40 [](
auto y,
auto high,
auto function,
auto name,
44 (
", but must be less than or equal to "
47 }(y, high, function, name, idxs...);
75 const T_y& y,
const T_high& high,
78 for (Eigen::Index i = 0; i < high_arr.size(); ++i) {
79 if (
unlikely(!(y <= high_arr.coeff(i)))) {
80 [](
auto y,
auto&& high_arr,
auto name,
auto function,
auto i,
84 (
", but must be less than or equal to "
85 + std::to_string(high_arr.coeff(i)))
87 }(y, high_arr, name, function, i, idxs...);
110template <
typename T_y,
typename T_high, require_stan_scalar_t<T_y>* =
nullptr,
111 require_dense_dynamic_t<T_high>* =
nullptr,
typename... Idxs>
113 const T_y& y,
const T_high& high,
116 for (Eigen::Index j = 0; j < high_arr.cols(); ++j) {
117 for (Eigen::Index i = 0; i < high_arr.rows(); ++i) {
118 if (
unlikely(!(y <= high_arr.coeff(i, j)))) {
119 [](
auto y,
auto&& high_arr,
auto name,
auto function,
auto i,
auto j,
124 (
", but must be less than or equal to "
125 + std::to_string(high_arr.coeff(i, j)))
127 }(y, high_arr, name, function, i, j, idxs...);
151template <
typename T_y,
typename T_high, require_vector_t<T_y>* =
nullptr,
152 require_not_std_vector_vt<is_container_or_var_matrix, T_y>* =
nullptr,
153 require_stan_scalar_t<T_high>* =
nullptr,
typename... Idxs>
155 const T_y& y,
const T_high& high,
158 for (Eigen::Index i = 0; i < y_arr.size(); ++i) {
159 if (
unlikely(!(y_arr.coeff(i) <= high))) {
160 [](
auto&& y_arr,
auto high,
auto name,
auto function,
auto i,
165 (
", but must be less than or equal to "
168 }(y_arr, high, name, function, i, idxs...);
191template <
typename T_y,
typename T_high,
192 require_dense_dynamic_t<T_y>* =
nullptr,
193 require_stan_scalar_t<T_high>* =
nullptr,
typename... Idxs>
195 const T_y& y,
const T_high& high,
198 for (Eigen::Index j = 0; j < y_arr.cols(); ++j) {
199 for (Eigen::Index i = 0; i < y_arr.rows(); ++i) {
200 if (
unlikely(!(y_arr.coeff(i, j) <= high))) {
201 [](
auto&& y_arr,
auto high,
auto name,
auto function,
auto i,
auto j,
206 (
", but must be less than or equal to "
209 }(y_arr, high, name, function, i, j, idxs...);
235template <
typename T_y,
typename T_high,
236 require_all_vector_t<T_y, T_high>* =
nullptr,
241 const T_y& y,
const T_high& high,
245 for (Eigen::Index i = 0; i < y_arr.size(); ++i) {
246 if (
unlikely(!(y_arr.coeff(i) <= high_arr.coeff(i)))) {
247 [](
auto&& y_arr,
auto&& high_arr,
auto name,
auto function,
auto i,
252 (
", but must be less than or equal to "
253 + std::to_string(high_arr.coeff(i)))
255 }(y_arr, high_arr, name, function, i, idxs...);
280template <
typename T_y,
typename T_high,
281 require_all_dense_dynamic_t<T_y, T_high>* =
nullptr,
typename... Idxs>
283 const T_y& y,
const T_high& high,
287 for (Eigen::Index j = 0; j < y_arr.cols(); ++j) {
288 for (Eigen::Index i = 0; i < y_arr.rows(); ++i) {
289 if (
unlikely(!(y_arr.coeff(i, j) <= high_arr.coeff(i, j)))) {
290 [](
auto&& y_arr,
auto&& high_arr,
auto name,
auto function,
auto i,
295 (
", but must be less than or equal to "
296 + std::to_string(high_arr.coeff(i, j)))
298 }(y_arr, high_arr, name, function, i, j, idxs...);
321template <
typename T_y,
typename T_high,
322 require_std_vector_vt<is_container_or_var_matrix, T_y>* =
nullptr,
323 require_not_std_vector_t<T_high>* =
nullptr,
typename... Idxs>
325 const T_y& y,
const T_high& high,
327 for (
size_t i = 0; i < y.size(); ++i) {
349template <
typename T_y,
typename T_high,
350 require_not_std_vector_t<T_y>* =
nullptr,
351 require_std_vector_vt<is_container_or_var_matrix, T_high>* =
nullptr,
354 const T_y& y,
const T_high& high,
356 for (
size_t i = 0; i < high.size(); ++i) {
379template <
typename T_y,
typename T_high,
382 require_all_std_vector_t<T_y, T_high>* =
nullptr,
typename... Idxs>
384 const T_y& y,
const T_high& high,
386 for (
size_t i = 0; i < y.size(); ++i) {
require_t< is_stan_scalar< std::decay_t< T > > > require_stan_scalar_t
Require type satisfies is_stan_scalar.
require_any_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check >... > require_any_std_vector_vt
Require any of the types satisfy is_std_vector.
require_not_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check... > > require_not_std_vector_vt
Require type does not satisfy is_std_vector or.
require_all_not_t< container_type_check_base< is_std_vector, value_type_t, TypeCheck, Check >... > require_all_not_std_vector_vt
Require none of the types satisfy is_std_vector.
require_t< is_vector< std::decay_t< T > > > require_vector_t
Require type satisfies is_vector.
auto make_iter_name(const char *name)
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
void check_less_or_equal(const char *function, const char *name, const T_y &y, const T_high &high, Idxs... idxs)
Throw an exception if y is not less than high.
T as_array_or_scalar(T &&v)
Returns specified input value.
void throw_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.
void throw_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.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
void throw_domain_error_mat(const char *function, const char *name, const T &y, size_t i, size_t j, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message for matrices.
bool_constant< math::disjunction< is_container< Container >, is_var_matrix< Container > >::value > is_container_or_var_matrix
Deduces whether type is eigen matrix, standard vector, or var<Matrix>.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...