1 #ifndef STAN_MATH_PRIM_FUN_IS_NAN_HPP 2 #define STAN_MATH_PRIM_FUN_IS_NAN_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 #include <cmath> 6 7 namespace stan { 8 namespace math { 9 10 /** 11 * Returns true if the input is NaN and false otherwise. 12 * 13 * Delegates to <code>std::isnan</code>. 14 * 15 * @param x Value to test. 16 * @return <code>true</code> if the value is NaN. 17 */ 18 template <typename T, typename = require_arithmetic_t<T>> is_nan(T x)19inline bool is_nan(T x) { 20 return std::isnan(x); 21 } 22 23 template <typename T, typename = require_eigen_t<T>> is_nan(const T & x)24inline bool is_nan(const T& x) { 25 return x.hasNan(); 26 } 27 28 } // namespace math 29 } // namespace stan 30 31 #endif 32