| Stan Math Library 2.12.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 namespace math {
10
19 template <typename T, typename S>
20 struct promote_scalar_struct<T, Eigen::Matrix<S, -1, -1> > {
29 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
30 apply(const Eigen::Matrix<S, -1, -1>& x) {
31 Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, -1>
32 y(x.rows(), x.cols());
33 for (int i = 0; i < x.size(); ++i)
34 y(i) = promote_scalar_struct<T, S>::apply(x(i));
35 return y;
36 }
37 };
38
47 template <typename T, typename S>
48 struct promote_scalar_struct<T, Eigen::Matrix<S, 1, -1> > {
57 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
58 apply(const Eigen::Matrix<S, 1, -1>& x) {
59 Eigen::Matrix<typename promote_scalar_type<T, S>::type, 1, -1>
60 y(x.rows(), x.cols());
61 for (int i = 0; i < x.size(); ++i)
62 y(i) = promote_scalar_struct<T, S>::apply(x(i));
63 return y;
64 }
65 };
66
75 template <typename T, typename S>
76 struct promote_scalar_struct<T, Eigen::Matrix<S, -1, 1> > {
85 static Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
86 apply(const Eigen::Matrix<S, -1, 1>& x) {
87 Eigen::Matrix<typename promote_scalar_type<T, S>::type, -1, 1>
88 y(x.rows(), x.cols());
89 for (int i = 0; i < x.size(); ++i)
90 y(i) = promote_scalar_struct<T, S>::apply(x(i));
91 return y;
92 }
93 };
94
95 }
96 }
97
98 #endif
99
100
promote_scalar_type.hpp
stan
Definition: log_sum_exp.hpp:8
Eigen
(Expert) Numerical traits for algorithmic differentiation variables.
Definition: Eigen_NumTraits.hpp:9
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:58
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:30
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:86

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