round.hpp
Go to the documentation of this file.
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>
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>
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
fvar< T > round(const fvar< T > &x)
Definition: round.hpp:23
int is_nan(const fvar< T > &x)
Definition: is_nan.hpp:19