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

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