1#ifndef STAN_MATH_PRIM_ERR_CHECK_SORTED_HPP
2#define STAN_MATH_PRIM_ERR_CHECK_SORTED_HPP
25template <
typename EigVec, require_eigen_vector_t<EigVec>* =
nullptr>
28 const auto& y_ref =
to_ref(y);
29 for (Eigen::Index n = 1; n < y_ref.size(); n++) {
30 if (!(y_ref[n] >= y_ref[n - 1])) {
31 std::ostringstream msg1;
32 msg1 <<
"is not a valid sorted vector."
34 std::string msg1_str(msg1.str());
35 std::ostringstream msg2;
36 msg2 <<
", but should be greater than or equal to the previous element, "
38 std::string msg2_str(msg2.str());
56template <
typename T_y>
58 const std::vector<T_y>& y) {
59 for (
size_t n = 1; n < y.size(); n++) {
60 if (!(y[n] >= y[n - 1])) {
61 std::ostringstream msg1;
62 msg1 <<
"is not a valid sorted vector."
64 std::string msg1_str(msg1.str());
65 std::ostringstream msg2;
66 msg2 <<
", but should be greater than or equal to the previous element, "
68 std::string msg2_str(msg2.str());
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_sorted(const char *function, const char *name, const EigVec &y)
Check if the specified vector is sorted into increasing order (repeated values are okay).
ref_type_t< T && > to_ref(T &&a)
This evaluates expensive Eigen expressions.
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...