Stan Math Library  2.10.0
reverse mode automatic differentiation
initialize_variable.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_MAT_FUN_INITIALIZE_VARIABLE_HPP
2 #define STAN_MATH_REV_MAT_FUN_INITIALIZE_VARIABLE_HPP
3 
5 #include <stan/math/rev/core.hpp>
6 #include <vector>
7 
8 namespace stan {
9  namespace math {
10 
15  inline void initialize_variable(var& variable, const var& value) {
16  variable = value;
17  }
18 
23  template <int R, int C>
24  inline void initialize_variable(Eigen::Matrix<var, R, C>& matrix,
25  const var& value) {
26  for (int i = 0; i < matrix.size(); ++i)
27  matrix(i) = value;
28  }
29 
33  template <typename T>
34  inline void initialize_variable(std::vector<T>& variables,
35  const var& value) {
36  for (size_t i = 0; i < variables.size(); ++i)
37  initialize_variable(variables[i], value);
38  }
39 
40  }
41 }
42 
43 #endif
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:31
void initialize_variable(var &variable, const var &value)
Initialize variable to value.

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