Stan Math Library  2.20.0
reverse mode automatic differentiation
is_positive.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_IS_POSITIVE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_IS_POSITIVE_HPP
3 
5 
6 namespace stan {
7 namespace math {
8 
17 template <typename T_y>
18 inline bool is_positive(const T_y& y) {
19  for (size_t n = 0; n < stan::length(y); ++n) {
20  if (!(stan::get(y, n) > 0))
21  return false;
22  }
23  return true;
24 }
25 
31 inline bool is_positive(int size) { return size > 0; }
32 
33 } // namespace math
34 } // namespace stan
35 #endif
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
Definition: length.hpp:16
bool is_positive(const T_y &y)
Return true if y is positive.
Definition: is_positive.hpp:18
T get(const std::vector< T > &x, size_t n)
Returns the n-th element of the provided std::vector.
Definition: get.hpp:16
int size(const std::vector< T > &x)
Return the size of the specified standard vector.
Definition: size.hpp:17

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