Stan Math Library: stan/math/prim/mat/fun/promote_scalar.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

promote_scalar.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_PROMOTE_SCALAR_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_PROMOTE_SCALAR_HPP
3
4 #include <stan/math/prim/scal/fun/promote_scalar.hpp>
5 #include <stan/math/prim/mat/fun/promote_scalar_type.hpp>
6 #include <stan/math/prim/mat/fun/Eigen.hpp>
7
8 namespace stan {
9
10 namespace math {
11
20 template <typename T, typename S>
21 struct promote_scalar_struct<T, Eigen::Matrix<S, -1, -1> > {
30 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
31 apply(const Eigen::Matrix<S, -1, -1>& x) {
32 Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
33 y(x.rows(), x.cols());
34 for (int i = 0; i < x.size(); ++i)
35 y(i) = promote_scalar_struct<T, S>::apply(x(i));
36 return y;
37 }
38 };
39
40
49 template <typename T, typename S>
50 struct promote_scalar_struct<T, Eigen::Matrix<S, 1, -1> > {
59 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
60 apply(const Eigen::Matrix<S, 1, -1>& x) {
61 Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
62 y(x.rows(), x.cols());
63 for (int i = 0; i < x.size(); ++i)
64 y(i) = promote_scalar_struct<T, S>::apply(x(i));
65 return y;
66 }
67 };
68
69
78 template <typename T, typename S>
79 struct promote_scalar_struct<T, Eigen::Matrix<S, -1, 1> > {
88 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
89 apply(const Eigen::Matrix<S, -1, 1>& x) {
90 Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
91 y(x.rows(), x.cols());
92 for (int i = 0; i < x.size(); ++i)
93 y(i) = promote_scalar_struct<T, S>::apply(x(i));
94 return y;
95 }
96 };
97
98
99 }
100 }
101
102
103 #endif
104
105
106
107
promote_scalar_type.hpp
stan
Definition: log_sum_exp.hpp:8
Eigen
(Expert) Numerical traits for algorithmic differentiation variables.
Definition: Eigen_NumTraits.hpp:8
stan::math::promote_scalar_struct
General struct to hold static function for promoting underlying scalar types.
Definition: promote_scalar.hpp:19
Eigen.hpp
stan::math::promote_scalar_struct< T, Eigen::Matrix< S, 1,-1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type, 1,-1 > apply(const Eigen::Matrix< S, 1,-1 > &x)
Return the column vector consisting of the recursive promotion of the elements of the input column ve...
Definition: promote_scalar.hpp:60
promote_scalar.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::math::promote_scalar_struct< T, Eigen::Matrix< S,-1,-1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type,-1,-1 > apply(const Eigen::Matrix< S,-1,-1 > &x)
Return the matrix consisting of the recursive promotion of the elements of the input matrix to the sc...
Definition: promote_scalar.hpp:31
stan::math::promote_scalar_struct< T, Eigen::Matrix< S,-1, 1 > >::apply
static Eigen::Matrix< typename promote_scalar_type< T, S >::type,-1, 1 > apply(const Eigen::Matrix< S,-1, 1 > &x)
Return the row vector consisting of the recursive promotion of the elements of the input row vector t...
Definition: promote_scalar.hpp:89

[ Stan Home Page ] © 2011–2016, Stan Development Team.