Stan Math Library  2.15.0
reverse mode automatic differentiation
check_positive_ordered.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_ERR_CHECK_POSITIVE_ORDERED_HPP
2 #define STAN_MATH_PRIM_MAT_ERR_CHECK_POSITIVE_ORDERED_HPP
3 
8 #include <sstream>
9 #include <string>
10 
11 namespace stan {
12  namespace math {
13 
27  template <typename T_y>
28  void
29  check_positive_ordered(const char* function,
30  const char* name,
31  const Eigen::Matrix<T_y, Eigen::Dynamic, 1>& y) {
32  using Eigen::Dynamic;
33  using Eigen::Matrix;
34 
35  if (y.size() == 0)
36  return;
37 
38  if (y[0] < 0) {
39  std::ostringstream msg;
40  msg << "is not a valid positive_ordered vector."
41  << " The element at " << stan::error_index::value
42  << " is ";
43  std::string msg_str(msg.str());
44  domain_error(function, name, y[0],
45  msg_str.c_str(), ", but should be postive.");
46  }
47  check_ordered(function, name, y);
48  }
49  }
50 }
51 #endif
void check_ordered(const char *function, const char *name, const std::vector< T_y > &y)
Check if the specified vector is sorted into strictly increasing order.
void check_positive_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
Check if the specified vector contains non-negative values and is sorted into strictly increasing ord...
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.

     [ Stan Home Page ] © 2011–2016, Stan Development Team.