Stan Math Library  2.15.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  namespace math {
11 
12  // initializations called for local variables generate in Stan
13  // code; fills in all cells in first arg with second arg
14 
15  template <typename T>
16  inline void initialize(T& x, const T& v) {
17  x = v;
18  }
19  template <typename T, typename V>
20  inline
21  typename boost::enable_if_c<boost::is_arithmetic<V>::value, void>::type
22  initialize(T& x, V v) {
23  x = v;
24  }
25  template <typename T, int R, int C, typename V>
26  inline void initialize(Eigen::Matrix<T, R, C>& x, const V& v) {
27  for (int i = 0; i < x.size(); ++i)
28  initialize(x(i), v);
29  }
30  template <typename T, typename V>
31  inline void initialize(std::vector<T>& x, const V& v) {
32  for (size_t i = 0; i < x.size(); ++i)
33  initialize(x[i], v);
34  }
35 
36  }
37 }
38 #endif
void initialize(T &x, const T &v)
Definition: initialize.hpp:16

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