Stan Math Library  2.15.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>,
21  Eigen::Matrix<S, R, C> > {
28  inline static Eigen::Matrix<T, R, C>
29  promote(const Eigen::Matrix<S, R, C>& u) {
30  Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic> t(u.rows(), u.cols());
31  for (int i = 0; i < u.size(); ++i)
33  return t;
34  }
35  };
36 
44  template <typename T, int R, int C>
45  struct promote_elements<Eigen::Matrix<T, R, C>,
46  Eigen::Matrix<T, R, C> > {
53  inline static const Eigen::Matrix<T, R, C>&
54  promote(const Eigen::Matrix<T, R, C>& u) {
55  return u;
56  }
57  };
58 
59  }
60 }
61 
62 #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–2016, Stan Development Team.