Skip to content

Commit abaf960

Browse files
committed
Specialize is_nan for ints
1 parent 9149f05 commit abaf960

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

stan/math/prim/fun/is_nan.hpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,34 @@ namespace stan {
88
namespace math {
99

1010
/**
11-
* Returns true if the input is NaN and false otherwise.
11+
* Tests if the input is Not a Number (NaN)
12+
*
13+
* Integer specialization, always return false.
14+
*
15+
* @tparam T Integer type.
16+
* @param x Value to test.
17+
* @return <code>false</code>.
18+
*/
19+
template <typename T, require_integral_t<T>* = nullptr>
20+
inline bool is_nan(T x) {
21+
return false;
22+
}
23+
24+
/**
25+
* Tests if the input is Not a Number (NaN)
1226
*
1327
* Delegates to <code>std::isnan</code>.
1428
*
29+
* @tparam T Floating point type.
1530
* @param x Value to test.
1631
* @return <code>true</code> if the value is NaN.
1732
*/
18-
template <typename T, typename = require_arithmetic_t<T>>
33+
template <typename T, require_floating_point_t<T>* = nullptr>
1934
inline bool is_nan(T x) {
2035
return std::isnan(x);
2136
}
2237

23-
template <typename T, typename = require_eigen_t<T>>
38+
template <typename T, require_eigen_t<T>* = nullptr>
2439
inline bool is_nan(const T& x) {
2540
return x.hasNan();
2641
}

0 commit comments

Comments
 (0)