1 #ifndef STAN_MATH_REV_META_RETURN_VAR_MATRIX
2 #define STAN_MATH_REV_META_RETURN_VAR_MATRIX
3 
4 #include <stan/math/rev/meta/is_var.hpp>
5 #include <stan/math/prim/meta.hpp>
6 
7 namespace stan {
8 
9 /**
10  * Given an Eigen type and several inputs, determine if a matrix should be
11  * `var<Matrix>` or `Matrix<var>`.
12  *
13  * `Matrix` will be a plain type
14  *
15  * @tparam ReturnType An Eigen matrix used for composing the `var<Matrix>` or
16  *  `Matrix<var>` type.
17  * @tparam Types Parameter pack holding any mix of types. If any of `Types`
18  *  are a `var<Matrix>` this holds a `var<Matrix>` type.
19  *  Else the type will be `Matrix<var>`
20  */
21 template <typename ReturnType, typename... Types>
22 using return_var_matrix_t = std::conditional_t<
23     is_any_var_matrix<ReturnType, Types...>::value,
24     stan::math::var_value<
25         stan::math::promote_scalar_t<double, plain_type_t<ReturnType>>>,
26     stan::math::promote_scalar_t<stan::math::var_value<double>,
27                                  plain_type_t<ReturnType>>>;
28 }  // namespace stan
29 
30 #endif
31