Stan Math Library  2.20.0
reverse mode automatic differentiation
check_finite.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_FINITE_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_FINITE_HPP
3 
8 #include <boost/math/special_functions/fpclassify.hpp>
9 
10 namespace stan {
11 namespace math {
12 
13 namespace internal {
14 template <typename T_y, bool is_vec>
15 struct finite {
16  static void check(const char* function, const char* name, const T_y& y) {
18  domain_error(function, name, y, "is ", ", but must be finite!");
19  }
20 };
21 
22 template <typename T_y>
23 struct finite<T_y, true> {
24  static void check(const char* function, const char* name, const T_y& y) {
25  for (size_t n = 0; n < stan::length(y); n++) {
27  domain_error_vec(function, name, y, n, "is ", ", but must be finite!");
28  }
29  }
30 };
31 } // namespace internal
32 
43 template <typename T_y>
44 inline void check_finite(const char* function, const char* name, const T_y& y) {
46 }
47 } // namespace math
48 } // namespace stan
49 #endif
void check_finite(const char *function, const char *name, const T_y &y)
Check if y is finite.
bool isfinite(const stan::math::var &v)
Checks if the given number has finite value.
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
size_t length(const std::vector< T > &x)
Returns the length of the provided std::vector.
Definition: length.hpp:16
void domain_error_vec(const char *function, const char *name, const T &y, size_t i, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
static void check(const char *function, const char *name, const T_y &y)
T get(const std::vector< T > &x, size_t n)
Returns the n-th element of the provided std::vector.
Definition: get.hpp:16
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.
static void check(const char *function, const char *name, const T_y &y)

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