1#ifndef STAN_MATH_PRIM_ERR_CHECK_SIMPLEX_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_SIMPLEX_HPP
33template <
typename T, require_matrix_t<T>* =
nullptr>
41 std::stringstream msg;
43 msg <<
"is not a valid simplex.";
45 msg <<
" sum(" << name <<
") = " <<
sum <<
", but should be ";
46 std::string msg_str(msg.str());
50 for (Eigen::Index n = 0; n < theta_ref.size(); n++) {
51 if (!(theta_ref.coeff(n) >= 0)) {
53 std::ostringstream msg;
54 msg <<
"is not a valid simplex. " << name <<
"["
57 std::string msg_str(msg.str());
59 ", but should be greater than or equal to 0");
81template <
typename T, require_std_vector_t<T>* =
nullptr>
82inline void check_simplex(
const char* function,
const char* name,
84 for (
size_t i = 0; i < theta.size(); ++i) {
auto make_iter_name(const char *name)
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
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 check_simplex(const char *function, const char *name, const T &theta)
Throw an exception if the specified vector is not a simplex.
auto sum(const std::vector< T > &m)
Return the sum of the entries of the specified standard vector.
void check_nonzero_size(const char *function, const char *name, const T_y &y)
Check if the specified matrix/vector is of non-zero size.
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds in rank and in simplexes.
fvar< T > fabs(const fvar< T > &x)
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...