1 #ifndef __STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_SIMPLEX_HPP__
2 #define __STAN__MATH__ERROR_HANDLING__MATRIX__CHECK_SIMPLEX_HPP__
27 template <
typename T_prob,
31 const Eigen::Matrix<T_prob,Eigen::Dynamic,1>& theta,
37 if (theta.size() == 0) {
38 std::string message(name);
39 message +=
" is not a valid simplex. %1% elements in the vector.";
40 T_result tmp = raise_domain_error<size_t, size_t>(
function,
49 std::stringstream msg;
50 T_prob
sum = theta.sum();
51 msg <<
"in function check_simplex(%1%), ";
52 msg << name <<
" is not a valid simplex.";
53 msg <<
" The sum of the elements should be 1, but is " <<
sum;
54 T_result tmp = raise_domain_error<T_result,T_prob>(
function,
62 for (
size_t n = 0; n < theta.size(); n++) {
63 if (!(theta[n] >= 0)) {
64 std::ostringstream stream;
65 stream << name <<
" is not a valid simplex."
66 <<
" The element at " << n
67 <<
" is %1%, but should be greater than or equal to 0";
69 = raise_domain_error<T_result,T_prob>(
function,
81 template <
typename T_y,
84 const Eigen::Matrix<T_y,Eigen::Dynamic,1>& theta,
91 const Eigen::Matrix<T,Eigen::Dynamic,1>& theta,