Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
check_not_nan.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_ERR_CHECK_NOT_NAN_HPP
2 #define STAN_MATH_PRIM_SCAL_ERR_CHECK_NOT_NAN_HPP
3 
9 #include <boost/math/special_functions/fpclassify.hpp>
10 
11 
12 namespace stan {
13  namespace math {
14 
15  namespace {
16  template <typename T_y, bool is_vec>
17  struct not_nan {
18  static bool check(const char* function,
19  const char* name,
20  const T_y& y) {
23  domain_error(function, name, y,
24  "is ", ", but must not be nan!");
25  return true;
26  }
27  };
28 
29  template <typename T_y>
30  struct not_nan<T_y, true> {
31  static bool check(const char* function,
32  const char* name,
33  const T_y& y) {
35  for (size_t n = 0; n < stan::length(y); n++) {
37  domain_error_vec(function, name, y, n,
38  "is ", ", but must not be nan!");
39  }
40  return true;
41  }
42  };
43  }
44 
62  template <typename T_y>
63  inline bool check_not_nan(const char* function,
64  const char* name,
65  const T_y& y) {
66  return not_nan<T_y, is_vector_like<T_y>::value>
67  ::check(function, name, y);
68  }
69 
70  }
71 }
72 #endif
bool check_not_nan(const char *function, const char *name, const T_y &y)
Return true if y is not NaN.
double value_of_rec(const fvar< T > &v)
Return the value of the specified variable.
size_t length(const std::vector< T > &x)
Definition: length.hpp:10
bool isnan(const stan::math::var &v)
Checks if the given number is NaN.
Definition: boost_isnan.hpp:22
void domain_error_vec(const char *function, const char *name, const T &y, const size_t i, const char *msg1, const char *msg2)
Throw a domain error with a consistently formatted message.
T get(const std::vector< T > &x, size_t n)
Definition: get.hpp:10
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–2015, Stan Development Team.