Stan Math Library  2.20.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 
4 #include <stan/math/rev/meta.hpp>
6 #include <stan/math/rev/core.hpp>
7 #include <vector>
8 
9 namespace stan {
10 namespace math {
11 
16 inline void initialize_variable(var& variable, const var& value) {
17  variable = value;
18 }
19 
24 template <int R, int C>
25 inline void initialize_variable(Eigen::Matrix<var, R, C>& matrix,
26  const var& value) {
27  for (int i = 0; i < matrix.size(); ++i)
28  matrix(i) = value;
29 }
30 
34 template <typename T>
35 inline void initialize_variable(std::vector<T>& variables, const var& value) {
36  for (size_t i = 0; i < variables.size(); ++i)
37  initialize_variable(variables[i], value);
38 }
39 
40 } // namespace math
41 } // namespace stan
42 
43 #endif
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:33
void initialize_variable(var &variable, const var &value)
Initialize variable to value.

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