| Stan Math Library 2.12.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/scal/err/domain_error.hpp>
5 #include <stan/math/prim/mat/err/check_ordered.hpp>
6 #include <stan/math/prim/mat/fun/Eigen.hpp>
7 #include <stan/math/prim/mat/meta/index_type.hpp>
8
9 #include <sstream>
10 #include <string>
11
12 namespace stan {
13 namespace math {
14
29 template <typename T_y>
30 bool
31 check_positive_ordered(const char* function,
32 const char* name,
33 const Eigen::Matrix<T_y, Eigen::Dynamic, 1>& y) {
34 using Eigen::Dynamic;
35 using Eigen::Matrix;
36
37 if (y.size() == 0) {
38 return true;
39 }
40 if (y[0] < 0) {
41 std::ostringstream msg;
42 msg << "is not a valid positive_ordered vector."
43 << " The element at " << stan::error_index::value
44 << " is ";
45 std::string msg_str(msg.str());
46 domain_error(function, name, y[0],
47 msg_str.c_str(), ", but should be postive.");
48 return false;
49 }
50 check_ordered(function, name, y);
51 return true;
52 }
53 }
54 }
55 #endif
stan
Definition: log_sum_exp.hpp:8
check_ordered.hpp
stan::math::check_ordered
bool check_ordered(const char *function, const char *name, const std::vector< T_y > &y)
Return true if the specified vector is sorted into strictly increasing order.
Definition: check_ordered.hpp:30
index_type.hpp
stan::error_index::value
Definition: error_index.hpp:7
stan::math::domain_error
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.
Definition: domain_error.hpp:30
Eigen.hpp
stan::math::check_positive_ordered
bool check_positive_ordered(const char *function, const char *name, const Eigen::Matrix< T_y, Eigen::Dynamic, 1 > &y)
Return true if the specified vector contains non-negative values and is sorted into strictly increasi...
Definition: check_positive_ordered.hpp:31
domain_error.hpp

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