value_of_rec.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_SCAL_FUN_VALUE_OF_REC_HPP
2 #define STAN_MATH_PRIM_SCAL_FUN_VALUE_OF_REC_HPP
3 
4 namespace stan {
5 namespace math {
6 
7 /**
8  * Return the value of the specified scalar argument
9  * converted to a double value.
10  *
11  * <p>See the <code>primitive_value</code> function to
12  * extract values without casting to <code>double</code>.
13  *
14  * <p>This function is meant to cover the primitive types. For
15  * types requiring pass-by-reference, this template function
16  * should be specialized.
17  *
18  * @tparam T Type of scalar.
19  * @param x Scalar to convert to double.
20  * @return Value of scalar cast to a double.
21  */
22 template <typename T>
23 inline double value_of_rec(const T x) {
24  return static_cast<double>(x);
25 }
26 
27 /**
28  * Return the specified argument.
29  *
30  * <p>See <code>value_of(T)</code> for a polymorphic
31  * implementation using static casts.
32  *
33  * <p>This inline pass-through no-op should be compiled away.
34  *
35  * @param x Specified value.
36  * @return Specified value.
37  */
38 template <>
39 inline double value_of_rec<double>(double x) {
40  return x;
41 }
42 
43 } // namespace math
44 } // namespace stan
45 #endif
double value_of_rec(const fvar< T > &v)
double value_of_rec< double >(double x)
double T
Definition: Xdiff_gwt.C:5