1 #ifndef STAN_MATH_PRIM_FUN_INT_STEP_HPP 2 #define STAN_MATH_PRIM_FUN_INT_STEP_HPP 3 4 #include <stan/math/prim/meta.hpp> 5 namespace stan { 6 namespace math { 7 8 /** 9 * The integer step, or Heaviside, function. 10 * 11 * For double NaN input, int_step(NaN) returns 0. 12 * 13 * \f[ 14 \mbox{int\_step}(x) = 15 \begin{cases} 16 0 & \mbox{if } x \leq 0 \\ 17 1 & \mbox{if } x > 0 \\[6pt] 18 0 & \mbox{if } x = \textrm{NaN} 19 \end{cases} 20 \f] 21 * 22 * @tparam T value type 23 * @param[in] y value 24 * @return 1 if value is greater than 0 and 0 otherwise 25 */ 26 template <typename T> int_step(const T & y)27inline int int_step(const T& y) { 28 return y > 0; 29 } 30 31 } // namespace math 32 } // namespace stan 33 #endif 34