1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_SIMPLEX_HPP 2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_SIMPLEX_HPP 38 template <
typename T_prob>
41 const Eigen::Matrix<T_prob, Eigen::Dynamic, 1>& theta) {
49 std::stringstream msg;
50 T_prob
sum = theta.sum();
51 msg <<
"is not a valid simplex.";
53 msg <<
" sum(" << name <<
") = " << sum
54 <<
", but should be ";
55 std::string msg_str(msg.str());
59 for (
size_t n = 0; n < theta.size(); n++) {
60 if (!(theta[n] >= 0)) {
61 std::ostringstream msg;
62 msg <<
"is not a valid simplex. " 65 std::string msg_str(msg.str());
68 ", but should be greater than or equal to 0");
fvar< T > sum(const std::vector< fvar< T > > &m)
Return the sum of the entries of the specified standard vector.
void check_simplex(const char *function, const char *name, const Eigen::Matrix< T_prob, Eigen::Dynamic, 1 > &theta)
Check if the specified vector is simplex.
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.
fvar< T > fabs(const fvar< T > &x)
const double CONSTRAINT_TOLERANCE
The tolerance for checking arithmetic bounds In rank and in simplexes.
Primary template class for the metaprogram to compute the index type of a container.
void 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.