Stan Math Library  2.12.0
reverse mode automatic differentiation
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 
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)
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)
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)
91  return y;
92  }
93  };
94 
95  }
96 }
97 
98 #endif
99 
100 
(Expert) Numerical traits for algorithmic differentiation variables.
General struct to hold static function for promoting underlying scalar types.
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...
static T apply(S x)
Return the value of the input argument promoted to the type specified by the template parameter...
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...
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...

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