Stan Math Library  2.6.3
probability, sampling & optimization
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Friends Macros
to_var.hpp
Go to the documentation of this file.
1 #ifndef STAN_MATH_REV_MAT_FUN_TO_VAR_HPP
2 #define STAN_MATH_REV_MAT_FUN_TO_VAR_HPP
3 
6 #include <stan/math/rev/core.hpp>
8 #include <vector>
9 
10 namespace stan {
11  namespace math {
12 
21  inline var to_var(const double& x) {
22  return var(x);
23  }
32  inline var to_var(const var& x) {
33  return x;
34  }
44  matrix_v m_v(m.rows(), m.cols());
45  for (int j = 0; j < m.cols(); ++j)
46  for (int i = 0; i < m.rows(); ++i)
47  m_v(i, j) = m(i, j);
48  return m_v;
49  }
58  inline matrix_v to_var(const matrix_v& m) {
59  return m;
60  }
71  vector_v v_v(v.size());
72  for (int i = 0; i < v.size(); ++i)
73  v_v[i] = v[i];
74  return v_v;
75  }
85  inline vector_v to_var(const vector_v& v) {
86  return v;
87  }
98  row_vector_v rv_v(rv.size());
99  for (int i = 0; i < rv.size(); ++i)
100  rv_v[i] = rv[i];
101  return rv_v;
102  }
112  inline row_vector_v to_var(const row_vector_v& rv) {
113  return rv;
114  }
115 
116  }
117 }
118 #endif
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding stan::math::var values.
Definition: typedefs.hpp:29
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
Definition: typedefs.hpp:30
Eigen::Matrix< double, 1, Eigen::Dynamic > row_vector_d
Type for (row) vector of double values.
Definition: typedefs.hpp:37
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > matrix_v
The type of a matrix holding stan::math::var values.
Definition: typedefs.hpp:21
var to_var(const double &x)
Converts argument to an automatic differentiation variable.
Definition: to_var.hpp:21
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:23
Eigen::Matrix< var, 1, Eigen::Dynamic > row_vector_v
The type of a row vector holding stan::math::var values.
Definition: typedefs.hpp:37

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