Stan Math Library  2.9.0
reverse mode automatic differentiation
initialize.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_PRIM_MAT_FUN_INITIALIZE_HPP
2 #define STAN_MATH_PRIM_MAT_FUN_INITIALIZE_HPP
3 
5 #include <boost/type_traits/is_arithmetic.hpp>
6 #include <boost/utility/enable_if.hpp>
7 #include <vector>
8 
9 namespace stan {
10 
11  namespace math {
12 
13  // initializations called for local variables generate in Stan
14  // code; fills in all cells in first arg with second arg
15 
16  template <typename T>
17  inline void initialize(T& x, const T& v) {
18  x = v;
19  }
20  template <typename T, typename V>
21  inline
22  typename boost::enable_if_c<boost::is_arithmetic<V>::value, void>::type
23  initialize(T& x, V v) {
24  x = v;
25  }
26  template <typename T, int R, int C, typename V>
27  inline void initialize(Eigen::Matrix<T, R, C>& x, const V& v) {
28  for (int i = 0; i < x.size(); ++i)
29  initialize(x(i), v);
30  }
31  template <typename T, typename V>
32  inline void initialize(std::vector<T>& x, const V& v) {
33  for (size_t i = 0; i < x.size(); ++i)
34  initialize(x[i], v);
35  }
36 
37  }
38 }
39 #endif
void initialize(T &x, const T &v)
Definition: initialize.hpp:17

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