Stan Math Library  2.20.0
reverse mode automatic differentiation
promote_elements.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_PROMOTE_ELEMENTS_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_PROMOTE_ELEMENTS_HPP
3 
6 
7 namespace stan {
8 namespace math {
9 
19 template <typename T, typename S, int R, int C>
20 struct promote_elements<Eigen::Matrix<T, R, C>, Eigen::Matrix<S, R, C> > {
27  inline static Eigen::Matrix<T, R, C> promote(
28  const Eigen::Matrix<S, R, C>& u) {
29  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> t(u.rows(), u.cols());
30  for (int i = 0; i < u.size(); ++i)
32  return t;
33  }
34 };
35 
43 template <typename T, int R, int C>
44 struct promote_elements<Eigen::Matrix<T, R, C>, Eigen::Matrix<T, R, C> > {
51  inline static const Eigen::Matrix<T, R, C>& promote(
52  const Eigen::Matrix<T, R, C>& u) {
53  return u;
54  }
55 };
56 
57 } // namespace math
58 } // namespace stan
59 
60 #endif
Struct with static function for elementwise type promotion.
static const Eigen::Matrix< T, R, C > & promote(const Eigen::Matrix< T, R, C > &u)
Return input matrix.
(Expert) Numerical traits for algorithmic differentiation variables.
static T promote(const S &u)
Return input element.
static Eigen::Matrix< T, R, C > promote(const Eigen::Matrix< S, R, C > &u)
Return input matrix of type S as matrix of type T.

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