| Stan Math Library 2.6.3 probability, sampling & optimization

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

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
4 #include <stan/math/prim/mat/fun/Eigen.hpp>
5 #include <stan/math/prim/mat/fun/typedefs.hpp>
6 #include <stan/math/rev/core.hpp>
7 #include <stan/math/rev/mat/fun/typedefs.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 }
43 inline matrix_v to_var(const stan::math::matrix_d& m) {
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 }
70 inline vector_v to_var(const stan::math::vector_d& v) {
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 }
97 inline row_vector_v to_var(const stan::math::row_vector_d& rv) {
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
core.hpp
stan::math::vector_v
Eigen::Matrix< var, Eigen::Dynamic, 1 > vector_v
The type of a (column) vector holding stan::math::var values.
Definition: typedefs.hpp:29
stan::math::vector_d
Eigen::Matrix< double, Eigen::Dynamic, 1 > vector_d
Type for (column) vector of double values.
Definition: typedefs.hpp:30
stan::math::row_vector_d
Eigen::Matrix< double, 1, Eigen::Dynamic > row_vector_d
Type for (row) vector of double values.
Definition: typedefs.hpp:37
stan::math::var
Independent (input) and dependent (output) variables for gradients.
Definition: var.hpp:32
stan::math::matrix_v
Eigen::Matrix< var, Eigen::Dynamic, Eigen::Dynamic > matrix_v
The type of a matrix holding stan::math::var values.
Definition: typedefs.hpp:21
stan::math::to_var
var to_var(const double &x)
Converts argument to an automatic differentiation variable.
Definition: to_var.hpp:21
typedefs.hpp
Eigen.hpp
stan::math::matrix_d
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > matrix_d
Type for matrix of double values.
Definition: typedefs.hpp:23
stan::math::row_vector_v
Eigen::Matrix< var, 1, Eigen::Dynamic > row_vector_v
The type of a row vector holding stan::math::var values.
Definition: typedefs.hpp:37
typedefs.hpp

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