1#ifndef STAN_MATH_PRIM_FUN_PROMOTE_SCALAR_HPP
2#define STAN_MATH_PRIM_FUN_PROMOTE_SCALAR_HPP
21template <
typename PromotionScalar,
typename UnPromotedType,
22 require_constructible_t<PromotionScalar, UnPromotedType>* =
nullptr,
23 require_not_same_t<PromotionScalar, UnPromotedType>* =
nullptr,
24 require_all_not_tuple_t<PromotionScalar, UnPromotedType>* =
nullptr>
26 return PromotionScalar(std::forward<UnPromotedType>(x));
38 typename PromotionScalar,
typename UnPromotedType,
41 return std::forward<UnPromotedType>(x);
52template <
typename PromotionScalar,
typename UnPromotedType,
57 return x.template cast<PromotionScalar>();
61template <
typename PromotionScalars,
typename UnPromotedTypes,
62 require_all_tuple_t<PromotionScalars, UnPromotedTypes>* =
nullptr,
64inline constexpr promote_scalar_t<PromotionScalars, UnPromotedTypes>
75template <
typename PromotionScalar,
typename UnPromotedType,
80 const auto x_size = x.size();
81 promote_scalar_t<PromotionScalar, UnPromotedType> ret(x_size);
82 for (
size_t i = 0; i < x_size; ++i) {
83 ret[i] = promote_scalar<PromotionScalar>(x[i]);
97template <
typename PromotionScalars,
typename UnPromotedTypes,
98 require_all_tuple_t<PromotionScalars, UnPromotedTypes>*,
99 require_not_same_t<PromotionScalars, UnPromotedTypes>*>
100inline constexpr promote_scalar_t<PromotionScalars, UnPromotedTypes>
102 return index_apply<std::tuple_size<std::decay_t<UnPromotedTypes>>::value>(
104 return std::make_tuple(
106 std::declval<PromotionScalars>()))>>(std::get<Is>(x))...);
require_t< is_eigen< std::decay_t< T > > > require_eigen_t
Require type satisfies is_eigen.
require_not_t< std::is_same< std::decay_t< T >, std::decay_t< S > > > require_not_same_t
Require types T and S does not satisfy std::is_same.
require_t< std::is_same< std::decay_t< T >, std::decay_t< S > > > require_same_t
Require types T and S satisfies std::is_same.
require_t< is_std_vector< std::decay_t< T > > > require_std_vector_t
Require type satisfies is_std_vector.
typename value_type< T >::type value_type_t
Helper function for accessing underlying type.
constexpr auto promote_scalar(UnPromotedType &&x)
Promote a scalar to another scalar type.
typename scalar_type< T >::type scalar_type_t
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...