Stan Math Library: stan/math/rev/mat/fun/to_var.hpp Source File

| Stan Math Library 2.10.0 reverse mode automatic differentiation

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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 <stan/math/rev/scal/fun/to_var.hpp>
9
10 namespace stan {
11 namespace math {
12
21 inline matrix_v to_var(const stan::math::matrix_d& m) {
22 matrix_v m_v(m.rows(), m.cols());
23 for (int j = 0; j < m.cols(); ++j)
24 for (int i = 0; i < m.rows(); ++i)
25 m_v(i, j) = m(i, j);
26 return m_v;
27 }
36 inline matrix_v to_var(const matrix_v& m) {
37 return m;
38 }
48 inline vector_v to_var(const stan::math::vector_d& v) {
49 vector_v v_v(v.size());
50 for (int i = 0; i < v.size(); ++i)
51 v_v[i] = v[i];
52 return v_v;
53 }
63 inline vector_v to_var(const vector_v& v) {
64 return v;
65 }
75 inline row_vector_v to_var(const stan::math::row_vector_d& rv) {
76 row_vector_v rv_v(rv.size());
77 for (int i = 0; i < rv.size(); ++i)
78 rv_v[i] = rv[i];
79 return rv_v;
80 }
90 inline row_vector_v to_var(const row_vector_v& rv) {
91 return rv;
92 }
93
94 }
95 }
96 #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
Definition: log_sum_exp.hpp:8
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::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
typedefs.hpp
to_var.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
stan::math::to_var
std::vector< var > to_var(const std::vector< double > &v)
Converts argument to an automatic differentiation variable.
Definition: to_var.hpp:20
typedefs.hpp

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