Stan Math Library
2.20.0
reverse mode automatic differentiation
stan
math
prim
scal
fun
promote_scalar.hpp
Go to the documentation of this file.
1
#ifndef STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_HPP
2
#define STAN_MATH_PRIM_SCAL_FUN_PROMOTE_SCALAR_HPP
3
4
#include <
stan/math/prim/meta.hpp
>
5
#include <
stan/math/prim/scal/fun/promote_scalar_type.hpp
>
6
7
namespace
stan
{
8
namespace
math {
9
18
template
<
typename
T,
typename
S>
19
struct
promote_scalar_struct
{
31
static
T
apply
(S x) {
return
T(x); }
32
};
33
41
template
<
typename
T>
42
struct
promote_scalar_struct
<T, T> {
49
static
T
apply
(
const
T& x) {
return
x; }
50
};
51
61
template
<
typename
T,
typename
S>
62
typename
promote_scalar_type<T, S>::type
promote_scalar
(
const
S& x) {
63
return
promote_scalar_struct<T, S>::apply
(x);
64
}
65
66
}
// namespace math
67
}
// namespace stan
68
#endif
stan
Definition:
log_sum_exp.hpp:8
meta.hpp
stan::math::promote_scalar_struct< T, T >::apply
static T apply(const T &x)
Return the unmodified input.
Definition:
promote_scalar.hpp:49
stan::math::promote_scalar
promote_scalar_type< T, S >::type promote_scalar(const S &x)
This is the top-level function to call to promote the scalar types of an input of type S to type T...
Definition:
promote_scalar.hpp:62
stan::math::promote_scalar_type::type
T type
The promoted type.
Definition:
promote_scalar_type.hpp:20
stan::math::promote_scalar_struct
General struct to hold static function for promoting underlying scalar types.
Definition:
promote_scalar.hpp:19
promote_scalar_type.hpp
stan::math::promote_scalar_struct::apply
static T apply(S x)
Return the value of the input argument promoted to the type specified by the template parameter...
Definition:
promote_scalar.hpp:31
[
Stan Home Page
]
© 2011–2018, Stan Development Team.