1#ifndef STAN_MATH_PRIM_ERR_CHECK_GREATER_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_GREATER_HPP
34template <
typename T_y,
typename T_low,
35 require_all_stan_scalar_t<T_y, T_low>* =
nullptr,
typename... Idxs>
36inline void check_greater(
const char* function,
const char* name,
const T_y& y,
37 const T_low& low, Idxs... idxs) {
39 [](
auto y,
auto low,
auto function,
auto name,
43 (
", but must be greater than " + std::to_string(
value_of_rec(low)))
45 }(y, low, function, name, idxs...);
72inline void check_greater(
const char* function,
const char* name,
const T_y& y,
73 const T_low& low, Idxs... idxs) {
75 for (Eigen::Index i = 0; i < low_arr.size(); ++i) {
76 if (
unlikely(!(y > low_arr.coeff(i)))) {
77 [](
auto y,
auto&& low_arr,
auto name,
auto function,
auto i,
81 (
", but must be greater than " + std::to_string(low_arr.coeff(i)))
83 }(y, low_arr, name, function, i, idxs...);
106template <
typename T_y,
typename T_low, require_stan_scalar_t<T_y>* =
nullptr,
107 require_dense_dynamic_t<T_low>* =
nullptr,
typename... Idxs>
108inline void check_greater(
const char* function,
const char* name,
const T_y& y,
109 const T_low& low, Idxs... idxs) {
111 for (Eigen::Index j = 0; j < low_arr.cols(); ++j) {
112 for (Eigen::Index i = 0; i < low_arr.rows(); ++i) {
113 if (
unlikely(!(y > low_arr.coeff(i, j)))) {
114 [](
auto y,
auto&& low_arr,
auto name,
auto function,
auto i,
auto j,
119 (
", but must be greater than "
120 + std::to_string(low_arr.coeff(i, j)))
122 }(y, low_arr, name, function, i, j, idxs...);
146template <
typename T_y,
typename T_low, require_vector_t<T_y>* =
nullptr,
147 require_not_std_vector_vt<is_container_or_var_matrix, T_y>* =
nullptr,
148 require_stan_scalar_t<T_low>* =
nullptr,
typename... Idxs>
149inline void check_greater(
const char* function,
const char* name,
const T_y& y,
150 const T_low& low, Idxs... idxs) {
152 for (Eigen::Index i = 0; i < y_arr.size(); ++i) {
153 if (
unlikely(!(y_arr.coeff(i) > low))) {
154 [](
auto&& y_arr,
auto low,
auto name,
auto function,
auto i,
159 (
", but must be greater than " + std::to_string(
value_of_rec(low)))
161 }(y_arr, low, name, function, i, idxs...);
184template <
typename T_y,
typename T_low, require_dense_dynamic_t<T_y>* =
nullptr,
185 require_stan_scalar_t<T_low>* =
nullptr,
typename... Idxs>
186inline void check_greater(
const char* function,
const char* name,
const T_y& y,
187 const T_low& low, Idxs... idxs) {
189 for (Eigen::Index j = 0; j < y_arr.cols(); ++j) {
190 for (Eigen::Index i = 0; i < y_arr.rows(); ++i) {
191 if (
unlikely(!(y_arr.coeff(i, j) > low))) {
192 [](
auto&& y_arr,
auto low,
auto name,
auto function,
auto i,
auto j,
197 (
", but must be greater than "
200 }(y_arr, low, name, function, i, j, idxs...);
226template <
typename T_y,
typename T_low,
227 require_all_vector_t<T_y, T_low>* =
nullptr,
231inline void check_greater(
const char* function,
const char* name,
const T_y& y,
232 const T_low& low, Idxs... idxs) {
235 for (Eigen::Index i = 0; i < low_arr.size(); ++i) {
236 if (
unlikely(!(y_arr.coeff(i) > low_arr.coeff(i)))) {
237 [](
auto&& y_arr,
auto&& low_arr,
auto name,
auto function,
auto i,
242 (
", but must be greater than " + std::to_string(low_arr.coeff(i)))
244 }(y_arr, low_arr, name, function, i, idxs...);
269template <
typename T_y,
typename T_low,
270 require_all_dense_dynamic_t<T_y, T_low>* =
nullptr,
typename... Idxs>
271inline void check_greater(
const char* function,
const char* name,
const T_y& y,
272 const T_low& low, Idxs... idxs) {
275 for (Eigen::Index j = 0; j < low_arr.cols(); ++j) {
276 for (Eigen::Index i = 0; i < low_arr.rows(); ++i) {
277 if (
unlikely(!(y_arr.coeff(i, j) > low_arr.coeff(i, j)))) {
278 [](
auto&& y_arr,
auto&& low_arr,
auto name,
auto function,
auto i,
283 (
", but must be greater than "
284 + std::to_string(low_arr.coeff(i, j)))
286 }(y_arr, low_arr, name, function, i, j, idxs...);
309template <
typename T_y,
typename T_low,
310 require_std_vector_vt<is_container_or_var_matrix, T_y>* =
nullptr,
311 require_not_std_vector_t<T_low>* =
nullptr,
typename... Idxs>
312inline void check_greater(
const char* function,
const char* name,
const T_y& y,
313 const T_low& low, Idxs... idxs) {
314 for (
size_t i = 0; i < y.size(); ++i) {
336template <
typename T_y,
typename T_low,
337 require_not_std_vector_t<T_y>* =
nullptr,
338 require_std_vector_vt<is_container_or_var_matrix, T_low>* =
nullptr,
340inline void check_greater(
const char* function,
const char* name,
const T_y& y,
341 const T_low& low, Idxs... idxs) {
342 for (
size_t i = 0; i < low.size(); ++i) {
365template <
typename T_y,
typename T_low,
368 require_all_std_vector_t<T_y, T_low>* =
nullptr,
typename... Idxs>
369inline void check_greater(
const char* function,
const char* name,
const T_y& y,
370 const T_low& low, Idxs... idxs) {
371 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.
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.
void check_greater(const char *function, const char *name, const T_y &y, const T_low &low, Idxs... idxs)
Throw an exception if y is not strictly greater than low.
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 ...