1 #ifndef STAN_MATH_FWD_SCAL_FUN_ROUND_HPP
2 #define STAN_MATH_FWD_SCAL_FUN_ROUND_HPP
3 
4 #include <stan/math/fwd/core.hpp>
5 #include <stan/math/prim/scal/fun/is_nan.hpp>
6 #include <stan/math/prim/scal/fun/round.hpp>
7 #include <limits>
8 
9 namespace stan {
10 namespace math {
11 
12 /**
13  * Return the closest integer to the specified argument, with
14  * halfway cases rounded away from zero.
15  *
16  * The derivative is always zero.
17  *
18  * @tparam T Scalar type for autodiff variable.
19  * @param x Argument.
20  * @return The rounded value of the argument.
21  */
22 template <typename T>
round(const fvar<T> & x)23 inline fvar<T> round(const fvar<T>& x) {
24   return fvar<T>(round(x.val_), is_nan(x.val_)
25                                     ? std::numeric_limits<double>::quiet_NaN()
26                                     : 0.0);
27 }
28 
29 }  // namespace math
30 }  // namespace stan
31 #endif
32